From nobody Mon Feb 9 00:56:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591203735; cv=none; d=zohomail.com; s=zohoarc; b=DnpVi/V5pB7fuKapVjkzJPRV6bcEKiEL+ClxwfSIxXc66wcI2GPLnTgkVDYcq4CwhDC9o7ImhkxRiW70lg2VGMfgOyAq8WngYRcoVqH3H0+damwvzIYQCrMDXzXvbybseDSgND3plRmTSvUJF4FxUx0IsGaPR8Z1UiRnVd8/3QE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591203735; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TurvwW0Opoosu2dOcdqQXkgvfWUn3Va/QqL3aIAfjo0=; b=gj64mngMxKpKsny0b4o8tjgcfYyCTytoBvM8hjVO2kxeJAA1CWpsp+pcsKXyXuauZYid2oQO/KG5gd8UnnlVBjat3SHWGGeOFHFSvzz7jMZLRvLGYjM4SZiWFNh+kF7Dwj8YVh7sLJmaZ/3S+xusO4jGkR28n9JAWLvzhxf1jBg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1591203735293840.4488035023862; Wed, 3 Jun 2020 10:02:15 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-398-X7Q4bP5-P4OUypW695N2RQ-1; Wed, 03 Jun 2020 13:02:11 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4A95E80058E; Wed, 3 Jun 2020 17:02:06 +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 0E06D98FE8; Wed, 3 Jun 2020 17:02:06 +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 C52E91809543; Wed, 3 Jun 2020 17:02:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 053H1twk006333 for ; Wed, 3 Jun 2020 13:01:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9D0E460BF4; Wed, 3 Jun 2020 17:01:55 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DDC460C81 for ; Wed, 3 Jun 2020 17:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591203733; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=TurvwW0Opoosu2dOcdqQXkgvfWUn3Va/QqL3aIAfjo0=; b=JUohoTN/uP41LfT+jPN0Pagfq/JNV7IPdBQIaDOM3MAnYN4oGBQ3mbH/NTkXFFCbJM9ZO5 OSRMqRKBRjgO/Kzr8g3Nui825eYef7wXJPNEdpWcpT2L7SfcmEWauUlMWicIath5CUlZLM NWlbBAYl4VsFWajV8jPAJ3i9w09iyTU= X-MC-Unique: X7Q4bP5-P4OUypW695N2RQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 6/6] qemu: Generate command line for -fw_cfg Date: Wed, 3 Jun 2020 19:01:38 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This is pretty straightforward and self explanatory. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1837990 Signed-off-by: Michal Privoznik --- src/qemu/qemu_command.c | 38 ++++++++++++++++++++++++++++++ tests/qemuxml2argvdata/fw_cfg.args | 32 +++++++++++++++++++++++++ tests/qemuxml2argvtest.c | 1 + 3 files changed, 71 insertions(+) create mode 100644 tests/qemuxml2argvdata/fw_cfg.args diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 419eca5675..b1e047690b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5794,6 +5794,41 @@ qemuBuildSmbiosCommandLine(virCommandPtr cmd, } =20 =20 +static int +qemuBuildFWCfgCommandLine(virCommandPtr cmd, + virQEMUCapsPtr qemuCaps, + const virDomainDef *def) +{ + size_t i; + + if (def->nfw_cfgs =3D=3D 0) + return 0; + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_FW_CFG)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("fw_cfg is not supported with this QEMU")); + return -1; + } + + for (i =3D 0; i < def->nfw_cfgs; i++) { + const virDomainFWCfgDef *f =3D &def->fw_cfgs[i]; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + + virBufferAsprintf(&buf, "name=3D%s", f->name); + + if (f->value) + virBufferEscapeString(&buf, ",string=3D%s", f->value); + else + virBufferEscapeString(&buf, ",file=3D%s", f->file); + + virCommandAddArg(cmd, "-fw_cfg"); + virCommandAddArgBuffer(cmd, &buf); + } + + return 0; +} + + static int qemuBuildVMGenIDCommandLine(virCommandPtr cmd, const virDomainDef *def) @@ -9634,6 +9669,9 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildSmbiosCommandLine(cmd, driver, def) < 0) return NULL; =20 + if (qemuBuildFWCfgCommandLine(cmd, qemuCaps, def) < 0) + return NULL; + if (qemuBuildVMGenIDCommandLine(cmd, def) < 0) return NULL; =20 diff --git a/tests/qemuxml2argvdata/fw_cfg.args b/tests/qemuxml2argvdata/fw= _cfg.args new file mode 100644 index 0000000000..95cbe55435 --- /dev/null +++ b/tests/qemuxml2argvdata/fw_cfg.args @@ -0,0 +1,32 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i386 \ +-name QEMUGuest1 \ +-S \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-m 214 \ +-realtime mlock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-fw_cfg 'name=3Dopt/com.example/name,string=3Dexample value' \ +-fw_cfg name=3Dopt/com.coreos/config,file=3D/tmp/provision.ign \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-usb \ +-drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ +-device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 3103cac884..dc10b30fe5 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1684,6 +1684,7 @@ mymain(void) DO_TEST("smbios", NONE); DO_TEST_PARSE_ERROR("smbios-date", NONE); DO_TEST_PARSE_ERROR("smbios-uuid-match", NONE); + DO_TEST("fw_cfg", QEMU_CAPS_FW_CFG); =20 DO_TEST("watchdog", NONE); DO_TEST("watchdog-device", NONE); --=20 2.26.2