
On 30/04/13 01:44, Eric Blake wrote:
* src/qemu/qemu_capabilities.h: New capability bit. * src/qemu/qemu_capabilities.c (virQEMUCapsProbeQMPCommandLine): New function; use it to set new capability bit. (virQEMUCapsInitQMP): Use new function. ---
As promised, here is how I would set the new capability for use in Osier's series here: https://www.redhat.com/archives/libvir-list/2013-April/msg01833.html
src/qemu/qemu_capabilities.c | 46 ++++++++++++++++++++++++++++++++++++++++---- src/qemu/qemu_capabilities.h | 1 + 2 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2acf535..40b824c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -222,9 +222,10 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "tpm-tis",
"nvram", /* 140 */ - "pci-bridge", /* 141 */ - "vfio-pci", /* 142 */ - "vfio-pci.bootindex", /* 143 */ + "pci-bridge", + "vfio-pci", + "vfio-pci.bootindex", + "mem-merge", );
struct _virQEMUCaps { @@ -1441,7 +1442,6 @@ static struct virQEMUCapsObjectTypeProps virQEMUCapsObjectProps[] = { ARRAY_CARDINALITY(virQEMUCapsObjectPropsUsbHost) }, };
- static void virQEMUCapsProcessStringFlags(virQEMUCapsPtr qemuCaps, size_t nflags, @@ -2225,6 +2225,42 @@ virQEMUCapsProbeQMPKVMState(virQEMUCapsPtr qemuCaps, }
+struct virQEMUCapsCommandLineProps { + const char *option; + const char *param; + int flag; +}; + +static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = { + { "machine", "mem-merge", QEMU_CAPS_MEM_MERGE }, +}; + +static int +virQEMUCapsProbeQMPCommandLine(virQEMUCapsPtr qemuCaps, + qemuMonitorPtr mon) +{ + int nvalues; + char **values; + size_t i, j; + + for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsCommandLine); i++) { + if ((nvalues = qemuMonitorGetCommandLineOptionParameters(mon, + virQEMUCapsCommandLine[i].option, + &values)) < 0) + return -1; + for (j = 0; j < nvalues; j++) { + if (STREQ(virQEMUCapsCommandLine[i].param, values[j])) { + virQEMUCapsSet(qemuCaps, virQEMUCapsCommandLine[i].flag); + break; + } + } + virStringFreeList(values);
values is leaked if the loop breaks. ACK with this fixed, but it will need rebasing, feel free to leave it to me, I can do it when rebasing the mem-merge patch. Osier