|
|
43fe83 |
From cf9c2028ba2892a200cd733617346e40069c1660 Mon Sep 17 00:00:00 2001
|
|
|
43fe83 |
Message-Id: <cf9c2028ba2892a200cd733617346e40069c1660.1380112457.git.jdenemar@redhat.com>
|
|
|
43fe83 |
From: Eric Blake <eblake@redhat.com>
|
|
|
43fe83 |
Date: Mon, 23 Sep 2013 11:10:04 -0600
|
|
|
43fe83 |
Subject: [PATCH] qemu: recognize -machine accel=kvm when parsing native
|
|
|
43fe83 |
|
|
|
43fe83 |
https://bugzilla.redhat.com/show_bug.cgi?id=1010617
|
|
|
43fe83 |
|
|
|
43fe83 |
In Fedora 19, 'qemu-kvm' is a simple wrapper that calls
|
|
|
43fe83 |
'qemu-system-x86_64 -machine accel=kvm'. Attempting
|
|
|
43fe83 |
to use 'virsh qemu-attach $pid' to a machine started as:
|
|
|
43fe83 |
|
|
|
43fe83 |
qemu-kvm -cdrom /var/lib/libvirt/images/foo.img \
|
|
|
43fe83 |
-monitor unix:/tmp/demo,server,nowait -name foo \
|
|
|
43fe83 |
--uuid cece4f9f-dff0-575d-0e8e-01fe380f12ea
|
|
|
43fe83 |
|
|
|
43fe83 |
was failing with:
|
|
|
43fe83 |
error: XML error: No PCI buses available
|
|
|
43fe83 |
|
|
|
43fe83 |
because we did not see 'kvm' in the executable name read from
|
|
|
43fe83 |
/proc/$pid/cmdline, and tried to assign os.machine as
|
|
|
43fe83 |
"accel=kvm" instead of "pc"; this in turn led to refusal to
|
|
|
43fe83 |
recognize the pci bus.
|
|
|
43fe83 |
|
|
|
43fe83 |
Noticed while investigating https://bugzilla.redhat.com/995312
|
|
|
43fe83 |
although there are still other issues to fix before that bug
|
|
|
43fe83 |
will be completely solved.
|
|
|
43fe83 |
|
|
|
43fe83 |
I've concluded that the existing parser code for native-to-xml
|
|
|
43fe83 |
is a horrendous hodge-podge of ad-hoc approaches; I basically
|
|
|
43fe83 |
rewrote the -machine section to be a bit saner.
|
|
|
43fe83 |
|
|
|
43fe83 |
* src/qemu/qemu_command.c (qemuParseCommandLine): Don't assume
|
|
|
43fe83 |
-machine argument is always appropriate for os.machine; set
|
|
|
43fe83 |
virtType if accel is present.
|
|
|
43fe83 |
|
|
|
43fe83 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
43fe83 |
(cherry picked from commit 2b1ef11c6cb14239feaeb1e426d85377983accb8)
|
|
|
43fe83 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
43fe83 |
---
|
|
|
43fe83 |
src/qemu/qemu_command.c | 57 +++++++++++++++++++++++++++----------------------
|
|
|
43fe83 |
1 file changed, 32 insertions(+), 25 deletions(-)
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
|
43fe83 |
index dd63e01..d596f09 100644
|
|
|
43fe83 |
--- a/src/qemu/qemu_command.c
|
|
|
43fe83 |
+++ b/src/qemu/qemu_command.c
|
|
|
43fe83 |
@@ -11172,35 +11172,42 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps,
|
|
|
43fe83 |
VIR_FREE(def->name);
|
|
|
43fe83 |
} else if (STREQ(arg, "-M") ||
|
|
|
43fe83 |
STREQ(arg, "-machine")) {
|
|
|
43fe83 |
- char *params;
|
|
|
43fe83 |
+ char **list;
|
|
|
43fe83 |
+ char *param;
|
|
|
43fe83 |
+ size_t j = 0;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+ /* -machine [type=]name[,prop[=value][,...]]
|
|
|
43fe83 |
+ * Set os.machine only if first parameter lacks '=' or
|
|
|
43fe83 |
+ * contains explicit type='...' */
|
|
|
43fe83 |
WANT_VALUE();
|
|
|
43fe83 |
- params = strchr(val, ',');
|
|
|
43fe83 |
- if (params == NULL) {
|
|
|
43fe83 |
- if (VIR_STRDUP(def->os.machine, val) < 0)
|
|
|
43fe83 |
- goto error;
|
|
|
43fe83 |
- } else {
|
|
|
43fe83 |
- if (VIR_STRNDUP(def->os.machine, val, params - val) < 0)
|
|
|
43fe83 |
+ list = virStringSplit(val, ",", 0);
|
|
|
43fe83 |
+ param = list[0];
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+ if (STRPREFIX(param, "type="))
|
|
|
43fe83 |
+ param += strlen("type=");
|
|
|
43fe83 |
+ if (!strchr(param, '=')) {
|
|
|
43fe83 |
+ if (VIR_STRDUP(def->os.machine, param) < 0) {
|
|
|
43fe83 |
+ virStringFreeList(list);
|
|
|
43fe83 |
goto error;
|
|
|
43fe83 |
-
|
|
|
43fe83 |
- while (params++) {
|
|
|
43fe83 |
- /* prepared for more "-machine" parameters */
|
|
|
43fe83 |
- char *tmp = params;
|
|
|
43fe83 |
- params = strchr(params, ',');
|
|
|
43fe83 |
-
|
|
|
43fe83 |
- if (STRPREFIX(tmp, "dump-guest-core=")) {
|
|
|
43fe83 |
- tmp += strlen("dump-guest-core=");
|
|
|
43fe83 |
- if (params && VIR_STRNDUP(tmp, tmp, params - tmp) < 0)
|
|
|
43fe83 |
- goto error;
|
|
|
43fe83 |
- def->mem.dump_core = virDomainMemDumpTypeFromString(tmp);
|
|
|
43fe83 |
- if (def->mem.dump_core <= 0)
|
|
|
43fe83 |
- def->mem.dump_core = VIR_DOMAIN_MEM_DUMP_DEFAULT;
|
|
|
43fe83 |
- if (params)
|
|
|
43fe83 |
- VIR_FREE(tmp);
|
|
|
43fe83 |
- } else if (STRPREFIX(tmp, "mem-merge=off")) {
|
|
|
43fe83 |
- def->mem.nosharepages = true;
|
|
|
43fe83 |
- }
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+ j++;
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+ /* handle all remaining "-machine" parameters */
|
|
|
43fe83 |
+ while ((param = list[j++])) {
|
|
|
43fe83 |
+ if (STRPREFIX(param, "dump-guest-core=")) {
|
|
|
43fe83 |
+ param += strlen("dump-guest-core=");
|
|
|
43fe83 |
+ def->mem.dump_core = virDomainMemDumpTypeFromString(param);
|
|
|
43fe83 |
+ if (def->mem.dump_core <= 0)
|
|
|
43fe83 |
+ def->mem.dump_core = VIR_DOMAIN_MEM_DUMP_DEFAULT;
|
|
|
43fe83 |
+ } else if (STRPREFIX(param, "mem-merge=off")) {
|
|
|
43fe83 |
+ def->mem.nosharepages = true;
|
|
|
43fe83 |
+ } else if (STRPREFIX(param, "accel=kvm")) {
|
|
|
43fe83 |
+ def->virtType = VIR_DOMAIN_VIRT_KVM;
|
|
|
43fe83 |
+ def->features |= (1 << VIR_DOMAIN_FEATURE_PAE);
|
|
|
43fe83 |
}
|
|
|
43fe83 |
}
|
|
|
43fe83 |
+ virStringFreeList(list);
|
|
|
43fe83 |
} else if (STREQ(arg, "-serial")) {
|
|
|
43fe83 |
WANT_VALUE();
|
|
|
43fe83 |
if (STRNEQ(val, "none")) {
|
|
|
43fe83 |
--
|
|
|
43fe83 |
1.8.3.2
|
|
|
43fe83 |
|