From nobody Wed May 14 15:50:32 2025 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523477493581659.0077234651486; Wed, 11 Apr 2018 13:11:33 -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 0BB4D81DE6; Wed, 11 Apr 2018 20:11:32 +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 D8AA1189BF; Wed, 11 Apr 2018 20:11:31 +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 9D53718033EB; Wed, 11 Apr 2018 20:11:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3BKBUrQ019671 for ; Wed, 11 Apr 2018 16:11:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6458665935; Wed, 11 Apr 2018 20:11:30 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-52.phx2.redhat.com [10.3.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 223277C254 for ; Wed, 11 Apr 2018 20:11:16 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 11 Apr 2018 16:10:04 -0400 Message-Id: <20180411201005.14749-10-jferlan@redhat.com> In-Reply-To: <20180411201005.14749-1-jferlan@redhat.com> References: <20180411201005.14749-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/10] qemu: Add VM Generation ID to qemu command line 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.25]); Wed, 11 Apr 2018 20:11:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1149445 If the domain requests usage of the genid functionality, then add the QEMU '-device vmgenid' to the command line providing either the supplied or generated GUID value. Add tests for both a generated and supplied GUID value. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 31 +++++++++++++++++++++++++++++++ tests/qemuxml2argvdata/genid-auto.args | 21 +++++++++++++++++++++ tests/qemuxml2argvdata/genid.args | 21 +++++++++++++++++++++ tests/qemuxml2argvtest.c | 4 ++++ 4 files changed, 77 insertions(+) create mode 100644 tests/qemuxml2argvdata/genid-auto.args create mode 100644 tests/qemuxml2argvdata/genid.args diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 955134d019..3b43cd4b56 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6023,6 +6023,34 @@ qemuBuildSmbiosCommandLine(virCommandPtr cmd, =20 =20 static int +qemuBuildVMGenIDCommandLine(virCommandPtr cmd, + const virDomainDef *def, + virQEMUCapsPtr qemuCaps) +{ + virBuffer opts =3D VIR_BUFFER_INITIALIZER; + char guid[VIR_UUID_STRING_BUFLEN]; + + if (!def->genidRequested) + return 0; + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMGENID)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("genid is not supported with this QEMU binary")); + return -1; + } + + virUUIDFormat(def->genid, guid); + virBufferAsprintf(&opts, "vmgenid,guid=3D%s,id=3Dvmgenid0", guid); + + virCommandAddArg(cmd, "-device"); + virCommandAddArgBuffer(cmd, &opts); + + virBufferFreeAndReset(&opts); + return 0; +} + + +static int qemuBuildSgaCommandLine(virCommandPtr cmd, const virDomainDef *def, virQEMUCapsPtr qemuCaps) @@ -10078,6 +10106,9 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildSmbiosCommandLine(cmd, driver, def, qemuCaps) < 0) goto error; =20 + if (qemuBuildVMGenIDCommandLine(cmd, def, qemuCaps) < 0) + goto error; + /* * NB, -nographic *MUST* come before any serial, or monitor * or parallel port flags due to QEMU craziness, where it diff --git a/tests/qemuxml2argvdata/genid-auto.args b/tests/qemuxml2argvdat= a/genid-auto.args new file mode 100644 index 0000000000..980cc077b9 --- /dev/null +++ b/tests/qemuxml2argvdata/genid-auto.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-system-x86_64 \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m 214 \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-device vmgenid,guid=3D00010203-0405-4607-8809-0a0b0c0d0e0f,id=3Dvmgenid0 \ +-nographic \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dreadline \ +-boot c \ +-usb diff --git a/tests/qemuxml2argvdata/genid.args b/tests/qemuxml2argvdata/gen= id.args new file mode 100644 index 0000000000..0d5dfde98f --- /dev/null +++ b/tests/qemuxml2argvdata/genid.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-system-x86_64 \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m 214 \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-device vmgenid,guid=3De9392370-2917-565e-692b-d057f46512d6,id=3Dvmgenid0 \ +-nographic \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dreadline \ +-boot c \ +-usb diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 3a328e02a2..343d8eb221 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -731,6 +731,10 @@ mymain(void) DO_TEST("minimal", NONE); DO_TEST_PARSE_ERROR("minimal-no-memory", NONE); DO_TEST("minimal-msg-timestamp", QEMU_CAPS_MSG_TIMESTAMP); + + DO_TEST("genid", QEMU_CAPS_DEVICE_VMGENID); + DO_TEST("genid-auto", QEMU_CAPS_DEVICE_VMGENID); + DO_TEST("machine-aliases1", NONE); DO_TEST("machine-aliases2", QEMU_CAPS_KVM); DO_TEST("machine-core-on", QEMU_CAPS_MACHINE_OPT, --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list