From: Zhenzhong Duan <zhenzhong.duan@intel.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, pbonzini@redhat.com
Subject: [PATCH] qdev: move legacy cli device creation after JSON syntax ones
Date: Wed, 23 Feb 2022 17:46:49 +0800 [thread overview]
Message-ID: <20220223094649.64566-1-zhenzhong.duan@intel.com> (raw)
While libvirt does not support all the qemu parameters in standand
xml syntax, such as hostfwd. We have to use <qemu:commandline> to
passthrough the parameters. E.x:
<qemu:commandline>
<qemu:arg value='-netdev'/>
<qemu:arg value='user,id=mynet0,hostfwd=tcp::44483-:22'/>
<qemu:arg value='-device'/>
<qemu:arg value='virtio-net-pci,netdev=mynet0,mac=00:16:3E:68:00:10,romfile='/>
</qemu:commandline>
Then we got below error:
qemu-system-x86_64: -device {"driver":"pcie-root-port","port":8,"chassis":1,"id":"pci.1","bus":"pcie.0","multifunction":true,"addr":"0x1"}: PCI: slot 1 function 0 not available for pcie-root-port, in use by virtio-net-pci
Libvirt generates qemu "-device" in JSON syntax followed by the
passthroughed "-device" in legacy syntax. But legacy syntax
described devices are assigned BDF first, this leads to conflict
with the pci devices in JSON syntax with fixed BDF.
Move legacy syntax described device creation after JSON syntax
described ones so we can start that kind of VM successfully in
libvirt.
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
softmmu/vl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 1fe028800fdf..5cf90e279fe9 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2682,8 +2682,6 @@ static void qemu_create_cli_devices(void)
/* init generic devices */
rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE);
- qemu_opts_foreach(qemu_find_opts("device"),
- device_init_func, NULL, &error_fatal);
QTAILQ_FOREACH(opt, &device_opts, next) {
DeviceState *dev;
loc_push_restore(&opt->loc);
@@ -2698,6 +2696,8 @@ static void qemu_create_cli_devices(void)
object_unref(OBJECT(dev));
loc_pop(&opt->loc);
}
+ qemu_opts_foreach(qemu_find_opts("device"),
+ device_init_func, NULL, &error_fatal);
rom_reset_order_override();
}
--
2.25.1
next reply other threads:[~2022-02-23 10:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-23 9:46 Zhenzhong Duan [this message]
2022-02-23 11:55 ` [PATCH] qdev: move legacy cli device creation after JSON syntax ones Peter Krempa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220223094649.64566-1-zhenzhong.duan@intel.com \
--to=zhenzhong.duan@intel.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).