Currently, -machine option is used only when dump-guest-core is set.
To use options defined in machine option for newer version of QEMU,
it needs to use -machine xxx, and to be compatible with older version
-M, this patch adds QEMU_CAPS_MACHINE_OPT capability for newer
version which supports -machine option.
Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
"megasas",
"ipv6-migration", /* 135 */
+ "machine-opt",
);
struct _virQEMUCaps {
if (strstr(help, "-dtb"))
virQEMUCapsSet(qemuCaps, QEMU_CAPS_DTB);
+ if (strstr(help, "-machine"))
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_OPT);
+
/*
* Handling of -incoming arg with varying features
* -incoming tcp (kvm >= 79, qemu >= 0.10.0)
virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_KVM_PIT);
virQEMUCapsSet(qemuCaps, QEMU_CAPS_DTB);
virQEMUCapsSet(qemuCaps, QEMU_CAPS_IPV6_MIGRATION);
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_OPT);
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_DUMP_GUEST_CORE);
}
/*
* qemu_capabilities.h: QEMU capabilities generation
*
- * Copyright (C) 2006-2012 Red Hat, Inc.
+ * Copyright (C) 2006-2013 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
QEMU_CAPS_DTB = 133, /* -dtb file */
QEMU_CAPS_SCSI_MEGASAS = 134, /* -device megasas */
QEMU_CAPS_IPV6_MIGRATION = 135, /* -incoming [::] */
+ QEMU_CAPS_MACHINE_OPT = 136, /* -machine xxxx*/
QEMU_CAPS_LAST, /* this must always be the last item */
};
if (!def->os.machine)
return 0;
- if (!def->mem.dump_core) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_OPT)) {
/* if no parameter to the machine type is needed, we still use
* '-M' to keep the most of the compatibility with older versions.
*/
virCommandAddArgList(cmd, "-M", def->os.machine, NULL);
- } else {
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DUMP_GUEST_CORE)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- "%s", _("dump-guest-core is not available "
- " with this QEMU binary"));
+ if (def->mem.dump_core) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("dump-guest-core is not available "
+ "with this QEMU binary"));
return -1;
}
+ } else {
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
- /* However, in case there is a parameter to be added, we need to
- * use the "-machine" parameter because qemu is not parsing the
- * "-M" correctly */
virCommandAddArg(cmd, "-machine");
- virCommandAddArgFormat(cmd,
- "%s,dump-guest-core=%s",
- def->os.machine,
- virDomainMemDumpTypeToString(def->mem.dump_core));
+ virBufferAdd(&buf, def->os.machine, -1);
+
+ if (def->mem.dump_core) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DUMP_GUEST_CORE)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("dump-guest-core is not available "
+ "with this QEMU binary"));
+ return -1;
+ }
+
+ virBufferAsprintf(&buf, ",dump-guest-core=%s",
+ virDomainMemDumpTypeToString(def->mem.dump_core));
+ }
+
+ virCommandAddArgBuffer(cmd, &buf);
}
return 0;
QEMU_CAPS_SCSI_LSI,
QEMU_CAPS_BLOCKIO,
QEMU_CAPS_VNC,
+ QEMU_CAPS_MACHINE_OPT,
QEMU_CAPS_DEVICE_QXL,
QEMU_CAPS_DEVICE_VGA,
QEMU_CAPS_DEVICE_CIRRUS_VGA,
QEMU_CAPS_VIRTIO_SCSI,
QEMU_CAPS_BLOCKIO,
QEMU_CAPS_VNC,
+ QEMU_CAPS_MACHINE_OPT,
QEMU_CAPS_DEVICE_QXL,
QEMU_CAPS_DEVICE_VGA,
QEMU_CAPS_DEVICE_CIRRUS_VGA,
QEMU_CAPS_SECCOMP_SANDBOX,
QEMU_CAPS_DUMP_GUEST_CORE,
QEMU_CAPS_VNC,
+ QEMU_CAPS_MACHINE_OPT,
QEMU_CAPS_USB_REDIR_BOOTINDEX,
QEMU_CAPS_USB_HOST_BOOTINDEX,
QEMU_CAPS_DEVICE_QXL,
QEMU_CAPS_SECCOMP_SANDBOX,
QEMU_CAPS_DUMP_GUEST_CORE,
QEMU_CAPS_VNC,
+ QEMU_CAPS_MACHINE_OPT,
QEMU_CAPS_USB_REDIR_BOOTINDEX,
QEMU_CAPS_USB_HOST_BOOTINDEX,
QEMU_CAPS_DEVICE_QXL,
DO_TEST("minimal-s390", QEMU_CAPS_NAME);
DO_TEST("machine-aliases1", NONE);
DO_TEST("machine-aliases2", QEMU_CAPS_KVM);
- DO_TEST("machine-core-on", QEMU_CAPS_DUMP_GUEST_CORE);
- DO_TEST("machine-core-off", QEMU_CAPS_DUMP_GUEST_CORE);
+ DO_TEST("machine-core-on", QEMU_CAPS_MACHINE_OPT,
+ QEMU_CAPS_DUMP_GUEST_CORE);
+ DO_TEST("machine-core-off", QEMU_CAPS_MACHINE_OPT,
+ QEMU_CAPS_DUMP_GUEST_CORE);
DO_TEST_FAILURE("machine-core-on", NONE);
+ DO_TEST_FAILURE("machine-core-on", QEMU_CAPS_MACHINE_OPT);
DO_TEST("boot-cdrom", NONE);
DO_TEST("boot-network", NONE);
DO_TEST("boot-floppy", NONE);