From nobody Mon Apr 29 04:32:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 150007580013199.33641429076249; Fri, 14 Jul 2017 16:43:20 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 258B93345BA; Fri, 14 Jul 2017 23:43:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5BC1719654; Fri, 14 Jul 2017 23:43:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 14FA44A492; Fri, 14 Jul 2017 23:43:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6ENhDjp023216 for ; Fri, 14 Jul 2017 19:43:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id AFBF81840D; Fri, 14 Jul 2017 23:43:13 +0000 (UTC) Received: from colepc.redhat.com (ovpn-116-206.phx2.redhat.com [10.3.116.206]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55F2C62920; Fri, 14 Jul 2017 23:43:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 258B93345BA Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 258B93345BA From: Cole Robinson To: libvirt-list@redhat.com Date: Fri, 14 Jul 2017 19:43:04 -0400 Message-Id: <342548c53a7b35880b906f7f5c37c996facd107b.1500075702.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/3] tests: add qemu x86 kvm 32-on-64 test X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 14 Jul 2017 23:43:18 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There's some specific logic in qemuBuildCpuCommandLine to support auto adding -cpu qemu 32 for arch=3Di686 with an x86_64 qemu-kvm binary. Add a test case for it Signed-off-by: Cole Robinson --- .../qemuxml2argv-x86-kvm-32-on-64.args | 21 +++++++++++++++++= ++++ .../qemuxml2argv-x86-kvm-32-on-64.xml | 13 +++++++++++++ tests/qemuxml2argvtest.c | 1 + tests/testutilsqemu.c | 18 ++++++++++++++++-- 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-x86-kvm-32-on-64.ar= gs create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-x86-kvm-32-on-64.xml diff --git a/tests/qemuxml2argvdata/qemuxml2argv-x86-kvm-32-on-64.args b/te= sts/qemuxml2argvdata/qemuxml2argv-x86-kvm-32-on-64.args new file mode 100644 index 000000000..5fdeaf843 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-x86-kvm-32-on-64.args @@ -0,0 +1,21 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-kvm \ +-name kvm \ +-S \ +-machine pc,accel=3Dkvm \ +-cpu qemu32 \ +-m 4096 \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid d091ea82-29e6-2e34-3005-f02617b36e87 \ +-nographic \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-kvm/monitor.soc= k,server,\ +nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dreadline \ +-no-acpi \ +-boot c diff --git a/tests/qemuxml2argvdata/qemuxml2argv-x86-kvm-32-on-64.xml b/tes= ts/qemuxml2argvdata/qemuxml2argv-x86-kvm-32-on-64.xml new file mode 100644 index 000000000..2939cec15 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-x86-kvm-32-on-64.xml @@ -0,0 +1,13 @@ + + kvm + d091ea82-29e6-2e34-3005-f02617b36e87 + 4194304 + + hvm + + + /usr/bin/qemu-kvm + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 302c9c892..ef5a9b0dc 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -690,6 +690,7 @@ mymain(void) DO_TEST("kvm", QEMU_CAPS_MACHINE_OPT); DO_TEST("default-kvm-host-arch", QEMU_CAPS_MACHINE_OPT); DO_TEST("default-qemu-host-arch", QEMU_CAPS_MACHINE_OPT); + DO_TEST("x86-kvm-32-on-64", QEMU_CAPS_MACHINE_OPT); DO_TEST("boot-cdrom", NONE); DO_TEST("boot-network", NONE); DO_TEST("boot-floppy", NONE); diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index ee4853841..d1290fdde 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -111,7 +111,8 @@ typedef enum { TEST_UTILS_QEMU_BIN_ARM, TEST_UTILS_QEMU_BIN_PPC64, TEST_UTILS_QEMU_BIN_PPC, - TEST_UTILS_QEMU_BIN_S390X + TEST_UTILS_QEMU_BIN_S390X, + TEST_UTILS_QEMU_BIN_KVM, } QEMUBinType; =20 static const char *QEMUBinList[] =3D { @@ -121,7 +122,8 @@ static const char *QEMUBinList[] =3D { "/usr/bin/qemu-system-arm", "/usr/bin/qemu-system-ppc64", "/usr/bin/qemu-system-ppc", - "/usr/bin/qemu-system-s390x" + "/usr/bin/qemu-system-s390x", + "/usr/bin/qemu-kvm", }; =20 =20 @@ -215,6 +217,18 @@ testQemuAddI686Guest(virCapsPtr caps) machines)) goto error; =20 + machines =3D NULL; + if (!(machines =3D testQemuAllocMachines(&nmachines))) + goto error; + + if (!virCapabilitiesAddGuestDomain(guest, + VIR_DOMAIN_VIRT_KVM, + QEMUBinList[TEST_UTILS_QEMU_BIN_KVM= ], + NULL, + nmachines, + machines)) + goto error; + return 0; =20 error: --=20 2.13.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 04:32:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1500075823274725.4373070250189; Fri, 14 Jul 2017 16:43:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BC188806A8; Fri, 14 Jul 2017 23:43:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7F47068D6D; Fri, 14 Jul 2017 23:43:39 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1D9351833033; Fri, 14 Jul 2017 23:43:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6ENhEQT023223 for ; Fri, 14 Jul 2017 19:43:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 36EB918398; Fri, 14 Jul 2017 23:43:14 +0000 (UTC) Received: from colepc.redhat.com (ovpn-116-206.phx2.redhat.com [10.3.116.206]) by smtp.corp.redhat.com (Postfix) with ESMTP id D31401840D; Fri, 14 Jul 2017 23:43:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BC188806A8 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BC188806A8 From: Cole Robinson To: libvirt-list@redhat.com Date: Fri, 14 Jul 2017 19:43:05 -0400 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] qemu: command: rework adding of default cpu model X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 14 Jul 2017 23:43:40 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Certain XML features that aren't in the block map to -cpu flags on the qemu cli. If one of these is specified but the user didn't explicitly pass an XML model, we need to format a default model on the command line. The current code handles this by sprinkling this default cpu handling among all the different flag string formatting. Instead, switch it to do this just once. This alters some test output slightly: the previous code would write the default -cpu in some cases when no flags were actually added, so the output was redundant. Signed-off-by: Cole Robinson --- src/qemu/qemu_command.c | 72 +++++++-----------= ---- .../qemuxml2argvdata/qemuxml2argv-hyperv-off.args | 1 - .../qemuxml2argv-kvm-features-off.args | 1 - 3 files changed, 22 insertions(+), 52 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b83261246..aa12479f7 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6714,11 +6714,11 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, virQEMUCapsPtr qemuCaps) { virArch hostarch =3D virArchFromHost(); - char *cpu =3D NULL; + char *cpu =3D NULL, *cpu_flags =3D NULL; bool hasHwVirt =3D false; const char *default_model; - bool have_cpu =3D false; int ret =3D -1; + virBuffer cpu_buf =3D VIR_BUFFER_INITIALIZER; virBuffer buf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 @@ -6729,9 +6729,8 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, =20 if (def->cpu && (def->cpu->mode !=3D VIR_CPU_MODE_CUSTOM || def->cpu->model)) { - if (qemuBuildCpuModelArgStr(driver, def, &buf, qemuCaps) < 0) + if (qemuBuildCpuModelArgStr(driver, def, &cpu_buf, qemuCaps) < 0) goto cleanup; - have_cpu =3D true; =20 /* Only 'svm' requires --enable-nesting. The nested 'vmx' patches = now * simply hook off the CPU features. */ @@ -6769,8 +6768,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, ((hostarch =3D=3D VIR_ARCH_X86_64 && strstr(def->emulator, "kvm")) || strstr(def->emulator, "x86_64"))) { - virBufferAdd(&buf, default_model, -1); - have_cpu =3D true; + virBufferAdd(&cpu_buf, default_model, -1); } } =20 @@ -6780,21 +6778,14 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, =20 if (timer->name =3D=3D VIR_DOMAIN_TIMER_NAME_KVMCLOCK && timer->present !=3D -1) { - virBufferAsprintf(&buf, "%s,%ckvmclock", - have_cpu ? "" : default_model, + virBufferAsprintf(&buf, ",%ckvmclock", timer->present ? '+' : '-'); - have_cpu =3D true; } else if (timer->name =3D=3D VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK && timer->present =3D=3D 1) { - virBufferAsprintf(&buf, "%s,hv_time", - have_cpu ? "" : default_model); - have_cpu =3D true; + virBufferAddLit(&buf, ",hv_time"); } else if (timer->name =3D=3D VIR_DOMAIN_TIMER_NAME_TSC && timer->frequency > 0) { - virBufferAsprintf(&buf, "%s,tsc-frequency=3D%lu", - have_cpu ? "" : default_model, - timer->frequency); - have_cpu =3D true; + virBufferAsprintf(&buf, ",tsc-frequency=3D%lu", timer->frequen= cy); } } =20 @@ -6805,10 +6796,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, else sign =3D '-'; =20 - virBufferAsprintf(&buf, "%s,%ckvm_pv_eoi", - have_cpu ? "" : default_model, - sign); - have_cpu =3D true; + virBufferAsprintf(&buf, ",%ckvm_pv_eoi", sign); } =20 if (def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK]) { @@ -6819,18 +6807,10 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, else sign =3D '-'; =20 - virBufferAsprintf(&buf, "%s,%ckvm_pv_unhalt", - have_cpu ? "" : default_model, - sign); - have_cpu =3D true; + virBufferAsprintf(&buf, ",%ckvm_pv_unhalt", sign); } =20 if (def->features[VIR_DOMAIN_FEATURE_HYPERV] =3D=3D VIR_TRISTATE_SWITC= H_ON) { - if (!have_cpu) { - virBufferAdd(&buf, default_model, -1); - have_cpu =3D true; - } - for (i =3D 0; i < VIR_DOMAIN_HYPERV_LAST; i++) { switch ((virDomainHyperv) i) { case VIR_DOMAIN_HYPERV_RELAXED: @@ -6866,22 +6846,12 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, =20 for (i =3D 0; i < def->npanics; i++) { if (def->panics[i]->model =3D=3D VIR_DOMAIN_PANIC_MODEL_HYPERV) { - if (!have_cpu) { - virBufferAdd(&buf, default_model, -1); - have_cpu =3D true; - } - virBufferAddLit(&buf, ",hv_crash"); break; } } =20 if (def->features[VIR_DOMAIN_FEATURE_KVM] =3D=3D VIR_TRISTATE_SWITCH_O= N) { - if (!have_cpu) { - virBufferAdd(&buf, default_model, -1); - have_cpu =3D true; - } - for (i =3D 0; i < VIR_DOMAIN_KVM_LAST; i++) { switch ((virDomainKVM) i) { case VIR_DOMAIN_KVM_HIDDEN: @@ -6898,12 +6868,8 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, =20 if (def->features[VIR_DOMAIN_FEATURE_PMU]) { virTristateSwitch pmu =3D def->features[VIR_DOMAIN_FEATURE_PMU]; - if (!have_cpu) - virBufferAdd(&buf, default_model, -1); - virBufferAsprintf(&buf, ",pmu=3D%s", virTristateSwitchTypeToString(pmu)); - have_cpu =3D true; } =20 if (def->cpu && def->cpu->cache) { @@ -6911,11 +6877,6 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, bool hostOff =3D false; bool l3Off =3D false; =20 - if (!have_cpu) { - virBufferAdd(&buf, default_model, -1); - have_cpu =3D true; - } - switch (cache->mode) { case VIR_CPU_CACHE_MODE_EMULATE: virBufferAddLit(&buf, ",l3-cache=3Don"); @@ -6945,13 +6906,22 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, virBufferAddLit(&buf, ",l3-cache=3Doff"); } =20 + if (virBufferCheckError(&cpu_buf) < 0) + goto cleanup; if (virBufferCheckError(&buf) < 0) goto cleanup; =20 - cpu =3D virBufferContentAndReset(&buf); + cpu =3D virBufferContentAndReset(&cpu_buf); + cpu_flags =3D virBufferContentAndReset(&buf); + + if (cpu_flags && !cpu) { + if (VIR_STRDUP(cpu, default_model) < 0) + goto cleanup; + } =20 if (cpu) { - virCommandAddArgList(cmd, "-cpu", cpu, NULL); + virCommandAddArg(cmd, "-cpu"); + virCommandAddArgFormat(cmd, "%s%s", cpu, cpu_flags ? cpu_flags : "= "); =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NESTING) && hasHwVirt) virCommandAddArg(cmd, "-enable-nesting"); @@ -6961,7 +6931,9 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, =20 cleanup: VIR_FREE(cpu); + VIR_FREE(cpu_flags); virBufferFreeAndReset(&buf); + virBufferFreeAndReset(&cpu_buf); return ret; } =20 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hyperv-off.args b/tests/qe= muxml2argvdata/qemuxml2argv-hyperv-off.args index e708feece..d1718d1f9 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-hyperv-off.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-hyperv-off.args @@ -8,7 +8,6 @@ QEMU_AUDIO_DRV=3Dnone \ -name QEMUGuest1 \ -S \ -M pc \ --cpu qemu32 \ -m 214 \ -smp 6,sockets=3D6,cores=3D1,threads=3D1 \ -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-kvm-features-off.args b/te= sts/qemuxml2argvdata/qemuxml2argv-kvm-features-off.args index e708feece..d1718d1f9 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-kvm-features-off.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-kvm-features-off.args @@ -8,7 +8,6 @@ QEMU_AUDIO_DRV=3Dnone \ -name QEMUGuest1 \ -S \ -M pc \ --cpu qemu32 \ -m 214 \ -smp 6,sockets=3D6,cores=3D1,threads=3D1 \ -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ --=20 2.13.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 04:32:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 150007579970384.1654895387478; Fri, 14 Jul 2017 16:43:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DAE1FC049D59; Fri, 14 Jul 2017 23:43:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 685AB6BF84; Fri, 14 Jul 2017 23:43:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A1CD81803B26; Fri, 14 Jul 2017 23:43:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6ENhEwW023228 for ; Fri, 14 Jul 2017 19:43:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id B72471840D; Fri, 14 Jul 2017 23:43:14 +0000 (UTC) Received: from colepc.redhat.com (ovpn-116-206.phx2.redhat.com [10.3.116.206]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D42318398; Fri, 14 Jul 2017 23:43:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DAE1FC049D59 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DAE1FC049D59 From: Cole Robinson To: libvirt-list@redhat.com Date: Fri, 14 Jul 2017 19:43:06 -0400 Message-Id: <6a8b5ec69544b9f2582b8b38e3bab1127da6358d.1500075702.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] qemu: command: explicitly error for non-x86 default CPU X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 14 Jul 2017 23:43:18 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The code only currently handles writing an x86 default -cpu argument, and doesn't know anything about other architectures. Let's make this explicit rather than leaving ex. qemu ppc64 to throw an error about -cpu qemu64 Signed-off-by: Cole Robinson --- src/qemu/qemu_command.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index aa12479f7..f727e3d30 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6716,17 +6716,11 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, virArch hostarch =3D virArchFromHost(); char *cpu =3D NULL, *cpu_flags =3D NULL; bool hasHwVirt =3D false; - const char *default_model; int ret =3D -1; virBuffer cpu_buf =3D VIR_BUFFER_INITIALIZER; virBuffer buf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 - if (def->os.arch =3D=3D VIR_ARCH_I686) - default_model =3D "qemu32"; - else - default_model =3D "qemu64"; - if (def->cpu && (def->cpu->mode !=3D VIR_CPU_MODE_CUSTOM || def->cpu->model)) { if (qemuBuildCpuModelArgStr(driver, def, &cpu_buf, qemuCaps) < 0) @@ -6768,7 +6762,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, ((hostarch =3D=3D VIR_ARCH_X86_64 && strstr(def->emulator, "kvm")) || strstr(def->emulator, "x86_64"))) { - virBufferAdd(&cpu_buf, default_model, -1); + virBufferAddLit(&cpu_buf, "qemu32"); } } =20 @@ -6915,6 +6909,23 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, cpu_flags =3D virBufferContentAndReset(&buf); =20 if (cpu_flags && !cpu) { + const char *default_model; + + switch (def->os.arch) { + case VIR_ARCH_I686: + default_model =3D "qemu32"; + break; + case VIR_ARCH_X86_64: + default_model =3D "qemu64"; + break; + default: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("CPU flags requested but can't determine " + "default CPU for arch %s"), + virArchToString(def->os.arch)); + goto cleanup; + } + if (VIR_STRDUP(cpu, default_model) < 0) goto cleanup; } --=20 2.13.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list