File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -543,19 +543,33 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
543543 return qtest_init_internal (qtest_qemu_binary (NULL ), extra_args );
544544}
545545
546- QTestState * qtest_init_with_env (const char * var , const char * extra_args )
546+ QTestState * qtest_init_with_env_and_capabilities (const char * var ,
547+ const char * extra_args ,
548+ QList * capabilities )
547549{
548550 QTestState * s = qtest_init_internal (qtest_qemu_binary (var ), extra_args );
549551 QDict * greeting ;
550552
551553 /* Read the QMP greeting and then do the handshake */
552554 greeting = qtest_qmp_receive (s );
553555 qobject_unref (greeting );
554- qobject_unref (qtest_qmp (s , "{ 'execute': 'qmp_capabilities' }" ));
556+ if (capabilities ) {
557+ qtest_qmp_assert_success (s ,
558+ "{ 'execute': 'qmp_capabilities', "
559+ "'arguments': { 'enable': %p } }" ,
560+ qobject_ref (capabilities ));
561+ } else {
562+ qtest_qmp_assert_success (s , "{ 'execute': 'qmp_capabilities' }" );
563+ }
555564
556565 return s ;
557566}
558567
568+ QTestState * qtest_init_with_env (const char * var , const char * extra_args )
569+ {
570+ return qtest_init_with_env_and_capabilities (var , extra_args , NULL );
571+ }
572+
559573QTestState * qtest_init (const char * extra_args )
560574{
561575 return qtest_init_with_env (NULL , extra_args );
Original file line number Diff line number Diff line change 1919
2020#include "qapi/qmp/qobject.h"
2121#include "qapi/qmp/qdict.h"
22+ #include "qapi/qmp/qlist.h"
2223#include "libqmp.h"
2324
2425typedef struct QTestState QTestState ;
@@ -68,6 +69,22 @@ QTestState *qtest_init(const char *extra_args);
6869 */
6970QTestState * qtest_init_with_env (const char * var , const char * extra_args );
7071
72+ /**
73+ * qtest_init_with_env_and_capabilities:
74+ * @var: Environment variable from where to take the QEMU binary
75+ * @extra_args: Other arguments to pass to QEMU. CAUTION: these
76+ * arguments are subject to word splitting and shell evaluation.
77+ * @capabilities: list of QMP capabilities (strings) to enable
78+ *
79+ * Like qtest_init_with_env(), but enable specified capabilities during
80+ * hadshake.
81+ *
82+ * Returns: #QTestState instance.
83+ */
84+ QTestState * qtest_init_with_env_and_capabilities (const char * var ,
85+ const char * extra_args ,
86+ QList * capabilities );
87+
7188/**
7289 * qtest_init_without_qmp_handshake:
7390 * @extra_args: other arguments to pass to QEMU. CAUTION: these
You can’t perform that action at this time.
0 commit comments