Re: [PATCH] tools: Fix typo firemare -> firmware
Ups, a horse on fire... ? :-) Sorry about it and thanks for saddling it. On 10/6/21 11:16 AM, Andrea Bolognani wrote: Signed-off-by: Andrea Bolognani --- Pushed as trivial. tools/virt-host-validate-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c index 556223242d..7a5cda4104 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -515,7 +515,7 @@ int virHostValidateSecureGuests(const char *hvname, } else { virHostMsgFail(level, "AMD Secure Encrypted Virtualization appears to be " - "disabled in firemare."); + "disabled in firmware."); return VIR_HOST_VALIDATE_FAILURE(level); } } -- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Gregor Pillen Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
Re: [libvirt PATCH 2/2] meson: Detect and reject invalid rst2html5 command
On Tue, Aug 10, 2021 at 05:02:54AM -0700, Andrea Bolognani wrote: > On Tue, Aug 10, 2021 at 11:05:42AM +0100, Daniel P. Berrangé wrote: > > On Mon, Aug 09, 2021 at 05:13:29PM +0200, Andrea Bolognani wrote: > > > The version coming from the rst2html5 package instead of the > > > docutils package is unable to successfully generate the libvirt > > > documentation. > > > > > > Examples of users encountering build issues because of the wrong > > > version of rst2html5 being installed on their systems: > > > > > > https://gitlab.com/libvirt/libvirt/-/issues/40 > > > https://gitlab.com/libvirt/libvirt/-/issues/139 > > > https://gitlab.com/libvirt/libvirt/-/issues/169 > > > https://gitlab.com/libvirt/libvirt/-/issues/195 > > > > > > Signed-off-by: Andrea Bolognani > > > --- > > > meson.build | 28 > > > 1 file changed, 28 insertions(+) > > > > > > diff --git a/meson.build b/meson.build > > > index 32ad688c9c..02357a2678 100644 > > > --- a/meson.build > > > +++ b/meson.build > > > @@ -813,6 +813,34 @@ foreach item : required_programs_groups > > >set_variable('@0@_prog'.format(varname), prog) > > > endforeach > > > > > > +# There are two versions of rst2html5 in the wild: one is the version > > > +# coming from the docutils package, and the other is the one coming > > > +# from the rst2html5 package. These versions are subtly different, > > > +# and the libvirt documentation can only be successfully generated > > > +# using the docutils version. Every now and then, users will report > > > +# build failures that can be traced back to having the wrong version > > > +# installed. > > > +# > > > +# The only reliable way to tell the two binaris apart seems to be > > > +# looking look at their version information: the docutils version > > > +# will report > > > +# > > > +# rst2html5 (Docutils ..., Python ..., on ...) > > > +# > > > +# whereas the rst2html5 version will report > > > +# > > > +# rst2html5 ... (Docutils ..., Python ..., on ...) > > > +# > > > +# with the additional bit of information being the version number for > > > +# the rst2html5 package itself. > > > > This feels way too fragile to me. > > > > Can't we just write out a 5 line rst doc showing the problem and > > try to run the command to detect brokeness ? > > Last time we discussed this, crafting a document that would trigger > one of the known differences in behavior was also deemed "kind of > fragile"[1]. > > Ultimately I don't think there's a way to tell the two binaries apart > which isn't at least a bit susceptible to breaking down the line, > especially because the rst2html5 package appears to be trying its > best to be a drop-in replacement - except of course for the things > that are different. > > That said, considering that the good rst2html5 binary comes from the > docutils package itself I don't really foresee a scenario where they > would have to introduce additional version information: it will > naturally be versioned the same as docutils itself. So this feels > like a reasonably future-proof detection method. > > Once again, I'm all hears when it comes to alternative ideas. AFAIK > nobody has manged to come up with something that we're all 100% happy > with, and I would hate to just leave things as they are because users > keep hitting the issue - which incidentally also means that > developers have to spend time debugging it and guiding them to the > solution every single time. > > > [1] https://listman.redhat.com/archives/libvir-list/2021-June/msg00196.html Resurrecting an old thread. Dan, should I consider your criticism of the approach an explicit NACK? If not, I will pick up Pavel's ACK and push this. I think the latter is the right thing to do, on the basis that it will leave us in a place that's strictly better than the status quo and that - to the best of my knowledge - no alternative that doesn't itself suffer from known drawbacks has been proposed. -- Andrea Bolognani / Red Hat / Virtualization
[PATCH] lxc: controller: Fix container launch on cgroup v1
With cgroup v1 I'm seeing LXC container startup failures: $ sudo virt-install --connect lxc:/// --name test-container --memory 128 --boot init=/bin/sh Starting install... ERRORerror from service: GDBus.Error:org.freedesktop.machine1.NoMachineForPID: PID 2145047 does not belong to any known machine libvirt 7.0.0 works but 7.1.0+ does not. The root error seems to predate that, showing up in syslog, but commit 9c1693eff made it fatal: commit 9c1693eff427661616ce1bd2795688f87288a412 Author: Pavel Hrdina Date: Fri Feb 5 16:17:35 2021 +0100 vircgroup: use DBus call to systemd for some APIs The error comes from virSystemdGetMachineByPID. The PID that shows up in the above error message does not match the leader PID as reported by machinectl. This change fixes the error. Things seem to continue to work with cgroupsv2 after this change. https://gitlab.com/libvirt/libvirt/-/issues/182 Signed-off-by: Cole Robinson --- This is from the thread in August, posted as non RFC now src/lxc/lxc_controller.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 8953e0c904..444f728af4 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -865,12 +865,12 @@ static int virLXCControllerSetupCgroupLimits(virLXCController *ctrl) nodeset = virDomainNumatuneGetNodeset(ctrl->def->numa, auto_nodeset, -1); if (!(ctrl->cgroup = virLXCCgroupCreate(ctrl->def, -ctrl->initpid, +getpid(), ctrl->nnicindexes, ctrl->nicindexes))) goto cleanup; -if (virCgroupAddMachineProcess(ctrl->cgroup, getpid()) < 0) +if (virCgroupAddMachineProcess(ctrl->cgroup, ctrl->initpid) < 0) goto cleanup; /* Add all qemu-nbd tasks to the cgroup */ -- 2.31.1
Re: [PATCH 4/5] qemuBuildNumaCommandLine: Separate out building of CPU list
On Thu, 30 Sep 2021 13:33:24 +0200 Peter Krempa wrote: > On Tue, Sep 21, 2021 at 16:50:30 +0200, Michal Privoznik wrote: > > Signed-off-by: Michal Privoznik > > --- > > src/qemu/qemu_command.c | 43 ++--- > > 1 file changed, 27 insertions(+), 16 deletions(-) > > Reviewed-by: Michal Privoznik ^^^ copy past err :)
Re: [PATCH 5/5] qemu: Prefer -numa cpu over -numa node,cpus=
On Thu, 30 Sep 2021 14:08:34 +0200 Peter Krempa wrote: > On Tue, Sep 21, 2021 at 16:50:31 +0200, Michal Privoznik wrote: > > QEMU is trying to obsolete -numa node,cpus= because that uses > > ambiguous vCPU id to [socket, die, core, thread] mapping. The new > > form is: > > > > -numa cpu,node-id=N,socket-id=S,die-id=D,core-id=C,thread-id=T > > > > which is repeated for every vCPU and places it at [S, D, C, T] > > into guest NUMA node N. > > > > While in general this is magic mapping, we can deal with it. > > Firstly, with QEMU 2.7 or newer, libvirt ensures that if topology > > is given then maxvcpus must be sockets * dies * cores * threads > > (i.e. there are no 'holes'). > > Secondly, if no topology is given then libvirt itself places each > > vCPU into a different socket (basically, it fakes topology of: > > [maxvcpus, 1, 1, 1]) > > Thirdly, we can copy whatever QEMU is doing when mapping vCPUs > > onto topology, to make sure vCPUs don't start to move around. > > There's a problem with this premise though and unfortunately we don't > seem to have qemuxml2argvtest for it. > > On PPC64, in certain situations the CPU can be configured such that > threads are visible only to VMs. This has substantial impact on how CPUs > are configured using the modern parameters (until now used only for > cpu hotplug purposes, and that's the reason vCPU hotplug has such > complicated incantations when starting the VM). > > In the above situation a CPU with topology of: > sockets=1, cores=4, threads=8 (thus 32 cpus) > > will only expose 4 CPU "devices". > > core-id: 0, core-id: 8, core-id: 16 and core-id: 24 > > yet the guest will correctly see 32 cpus when used as such. > > You can see this in: > > tests/qemuhotplugtestcpus/ppc64-modern-individual-monitor.json > > Also note that the 'props' object does _not_ have any socket-id, and > management apps are supposed to pass in 'props' as is. (There's a bunch > of code to do that on hotplug). > > The problem is that you need to query the topology first (unless we want > to duplicate all of qemu code that has to do with topology state and > keep up with changes to it) to know how it's behaving on current > machine. This historically was not possible. The supposed solution for > this was the pre-config state where we'd be able to query and set it up > via QMP, but I was not keeping up sufficiently with that work, so I > don't know if it's possible. > > If preconfig is a viable option we IMO should start using it sooner > rather than later and avoid duplicating qemu's logic here. using preconfig is preferable variant otherwise libvirt would end up duplicating topology logic which differs not only between targets but also between machine/cpu types. Closest example how to use preconfig is in pc_dynamic_cpu_cfg() test case. Though it uses query-hotpluggable-cpus only for verification, but one can use the command at the preconfig stage to get topology for given -smp/-machine type combination. > > > Note, migration from old to new cmd line works and therefore > > doesn't need any special handling. > > > > Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1678085 > > Signed-off-by: Michal Privoznik > > --- > > src/qemu/qemu_command.c | 112 +- > > .../hugepages-nvdimm.x86_64-latest.args | 4 +- > > ...memory-default-hugepage.x86_64-latest.args | 10 +- > > .../memfd-memory-numa.x86_64-latest.args | 10 +- > > ...y-hotplug-nvdimm-access.x86_64-latest.args | 4 +- > > ...ory-hotplug-nvdimm-align.x86_64-5.2.0.args | 4 +- > > ...ry-hotplug-nvdimm-align.x86_64-latest.args | 4 +- > > ...ory-hotplug-nvdimm-label.x86_64-5.2.0.args | 4 +- > > ...ry-hotplug-nvdimm-label.x86_64-latest.args | 4 +- > > ...mory-hotplug-nvdimm-pmem.x86_64-5.2.0.args | 4 +- > > ...ory-hotplug-nvdimm-pmem.x86_64-latest.args | 4 +- > > ...-hotplug-nvdimm-readonly.x86_64-5.2.0.args | 4 +- > > ...hotplug-nvdimm-readonly.x86_64-latest.args | 4 +- > > .../memory-hotplug-nvdimm.x86_64-latest.args | 4 +- > > ...mory-hotplug-virtio-pmem.x86_64-5.2.0.args | 4 +- > > ...ory-hotplug-virtio-pmem.x86_64-latest.args | 4 +- > > .../numatune-hmat.x86_64-latest.args | 18 ++- > > ...emnode-restrictive-mode.x86_64-latest.args | 38 +- > > .../numatune-memnode.x86_64-5.2.0.args| 38 +- > > .../numatune-memnode.x86_64-latest.args | 38 +- > > ...vhost-user-fs-fd-memory.x86_64-latest.args | 4 +- > > ...vhost-user-fs-hugepages.x86_64-latest.args | 4 +- > > ...host-user-gpu-secondary.x86_64-latest.args | 3 +- > > .../vhost-user-vga.x86_64-latest.args | 3 +- > > 24 files changed, 296 insertions(+), 34 deletions(-) > > > > diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c > > index f04ae1e311..5192bd7630 100644 > > --- a/src/qemu/qemu_command.c > > +++ b/src/qemu/qemu_command.c > > [...] > > > @@ -7432,6 +7432,94 @@ qemuBuildNumaCPUs(virBuffer *buf, >
Re: [PATCH 09/11] qdev: Avoid QemuOpts in QMP device_add
Kevin Wolf wrote: > Am 05.10.2021 um 17:52 hat Damien Hedde geschrieben: Hi >> > Usage >> > - >> > >> > The primary device can be hotplugged or be part of the startup >> > configuration >> > >> > -device virtio-net-pci,netdev=hostnet1,id=net1, >> > mac=52:54:00:6f:55:cc,bus=root2,failover=on >> > >> > With the parameter failover=on the VIRTIO_NET_F_STANDBY feature >> > will be enabled. >> > >> > -device vfio-pci,host=5e:00.2,id=hostdev0,bus=root1, >> > failover_pair_id=net1 >> > >> > failover_pair_id references the id of the virtio-net standby device. >> > This is only for pairing the devices within QEMU. The guest kernel >> > module net_failover will match devices with identical MAC addresses. >> > >> > Hotplug >> > --- >> > >> > Both primary and standby device can be hotplugged via the QEMU >> > monitor. Note that if the virtio-net device is plugged first a >> > warning will be issued that it couldn't find the primary device. >> >> So maybe this whole primary device lookup can happen during the -device CLI >> option creation loop. And we can indeed have un-created devices still in the >> list ? > > Yes, that's the only case for which I could imagine for an inconsistency > between the qdev tree and QemuOpts, but failover_add_primary() is only > called after feature negotiation with the guest driver, so we can be > sure that the -device loop has completed long ago. > > And even if it hadn't completed yet, the paragraph also says that even > hotplugging the device later is supported, so creating devices in the > wrong order should still succeed. > > I hope that some of the people I added to CC have some more hints. Failover is ... interesting. You have two devices: primary and seconday. seconday is virtio-net, primary can be vfio and some other emulated devices. In the command line, devices can appear on any order, primary then secondary, secondary then primary, or only one of them. You can add (any of them) later in the toplevel. And now, what all this mess is about. We only enable the primary if the guest knows about failover. Otherwise we use only the virtio device (*). The important bit here is that we need to wait until the guest is booted, and the virtio-net driver is loaded, and then it tells us if it understands failover (or not). At that point we decide if we want to "really" create the primary. I know that it abuses device_add() as much as it can be, but I can't see any better way to handle it. We need to be able to "create" a device without showing it to the guest. And later, when we create a different device, and depending of driver support on the guest, we "finish" the creation of the primary device. Any good idea? Later, Juan. *: This changed recently and we can only have the "primary" and not the virtio one, but it doesn't matter on this discussion.
Re: [PATCH 09/11] qdev: Avoid QemuOpts in QMP device_add
On 06/10/2021 12:53, Kevin Wolf wrote: Am 06.10.2021 um 11:20 hat Laurent Vivier geschrieben: On 06/10/2021 10:21, Juan Quintela wrote: Kevin Wolf wrote: Am 05.10.2021 um 17:52 hat Damien Hedde geschrieben: Hi Usage - The primary device can be hotplugged or be part of the startup configuration -device virtio-net-pci,netdev=hostnet1,id=net1, mac=52:54:00:6f:55:cc,bus=root2,failover=on With the parameter failover=on the VIRTIO_NET_F_STANDBY feature will be enabled. -device vfio-pci,host=5e:00.2,id=hostdev0,bus=root1, failover_pair_id=net1 failover_pair_id references the id of the virtio-net standby device. This is only for pairing the devices within QEMU. The guest kernel module net_failover will match devices with identical MAC addresses. Hotplug --- Both primary and standby device can be hotplugged via the QEMU monitor. Note that if the virtio-net device is plugged first a warning will be issued that it couldn't find the primary device. So maybe this whole primary device lookup can happen during the -device CLI option creation loop. And we can indeed have un-created devices still in the list ? Yes, that's the only case for which I could imagine for an inconsistency between the qdev tree and QemuOpts, but failover_add_primary() is only called after feature negotiation with the guest driver, so we can be sure that the -device loop has completed long ago. And even if it hadn't completed yet, the paragraph also says that even hotplugging the device later is supported, so creating devices in the wrong order should still succeed. I hope that some of the people I added to CC have some more hints. Failover is ... interesting. You have two devices: primary and seconday. seconday is virtio-net, primary can be vfio and some other emulated devices. In the command line, devices can appear on any order, primary then secondary, secondary then primary, or only one of them. You can add (any of them) later in the toplevel. And now, what all this mess is about. We only enable the primary if the guest knows about failover. Otherwise we use only the virtio device (*). The important bit here is that we need to wait until the guest is booted, and the virtio-net driver is loaded, and then it tells us if it understands failover (or not). At that point we decide if we want to "really" create the primary. I know that it abuses device_add() as much as it can be, but I can't see any better way to handle it. We need to be able to "create" a device without showing it to the guest. And later, when we create a different device, and depending of driver support on the guest, we "finish" the creation of the primary device. Any good idea? Hm, the naive idea would be creating the device without attaching it to any bus. But I suppose qdev doesn't let you do that. Anyway, the part that I missed yesterday is that qdev_device_add() already skips creating the device if qdev_should_hide_device(), which explains how the inconsistency is created. (As an aside, it then returns NULL without setting an error to indicate success, which is an awkward interface, and sure enough, qmp_device_add() gets it wrong and deletes the QemuOpts again. So hotplugging the virtio-net standby device doesn't even seem to work?) Could we just save the configuration in the .hide_device callback (i.e. failover_hide_primary_device() in virtio-net) to a new field in VirtIONet and then use that when actually creating the device instead of accessing the command line state in the QemuOptsList? It seems that we can currently add two primary devices that are then both hidden. failover_add_primary() adds only one of them, leaving the other one hidden. Is this a bug and we should reject such a configuration or do we need to support keeping configurations for multiple primary devices in a single standby device? This would still be ugly because the configuration is only really validated when the primary device is actually added instead of immediately on -device/device_add, but at least it would keep the ugliness more local and wouldn't block the move away from QemuOpts (the config would just be stored as a QDict after my patches). I don't know if it can help the discussion, but I'm reformatting the failover code to move all the PCI stuff to pci files. And there is a lot of inconsistencies regarding the device_add and --device option so I've been in the end to add a list of of hidden devices rather than relying on the command line. See PATCH 8 of series "[RFC PATCH v2 0/8] virtio-net failover cleanup and new features" https://patchew.org/QEMU/20210820142002.152994-1-lviv...@redhat.com/ While it's certainly an improvement over the current state, we really should move away from QemuOpts and I think using global state for this I totally agree with that. is wrong anyway. So it feels like it's not the change we need here, but more a step sideways. Yes, I wanted to fix the problem without modifying to m
Re: [PATCH 09/11] qdev: Avoid QemuOpts in QMP device_add
Am 06.10.2021 um 11:20 hat Laurent Vivier geschrieben: > On 06/10/2021 10:21, Juan Quintela wrote: > > Kevin Wolf wrote: > > > Am 05.10.2021 um 17:52 hat Damien Hedde geschrieben: > > > > Hi > > > > > > > Usage > > > > > - > > > > > > > > > > The primary device can be hotplugged or be part of the startup > > > > > configuration > > > > > > > > > >-device virtio-net-pci,netdev=hostnet1,id=net1, > > > > >mac=52:54:00:6f:55:cc,bus=root2,failover=on > > > > > > > > > > With the parameter failover=on the VIRTIO_NET_F_STANDBY feature > > > > > will be enabled. > > > > > > > > > > -device vfio-pci,host=5e:00.2,id=hostdev0,bus=root1, > > > > > failover_pair_id=net1 > > > > > > > > > > failover_pair_id references the id of the virtio-net standby device. > > > > > This is only for pairing the devices within QEMU. The guest kernel > > > > > module net_failover will match devices with identical MAC addresses. > > > > > > > > > > Hotplug > > > > > --- > > > > > > > > > > Both primary and standby device can be hotplugged via the QEMU > > > > > monitor. Note that if the virtio-net device is plugged first a > > > > > warning will be issued that it couldn't find the primary device. > > > > > > > > So maybe this whole primary device lookup can happen during the -device > > > > CLI > > > > option creation loop. And we can indeed have un-created devices still > > > > in the > > > > list ? > > > > > > Yes, that's the only case for which I could imagine for an inconsistency > > > between the qdev tree and QemuOpts, but failover_add_primary() is only > > > called after feature negotiation with the guest driver, so we can be > > > sure that the -device loop has completed long ago. > > > > > > And even if it hadn't completed yet, the paragraph also says that even > > > hotplugging the device later is supported, so creating devices in the > > > wrong order should still succeed. > > > > > > I hope that some of the people I added to CC have some more hints. > > > > Failover is ... interesting. > > > > You have two devices: primary and seconday. > > seconday is virtio-net, primary can be vfio and some other emulated > > devices. > > > > In the command line, devices can appear on any order, primary then > > secondary, secondary then primary, or only one of them. > > You can add (any of them) later in the toplevel. > > > > And now, what all this mess is about. We only enable the primary if the > > guest knows about failover. Otherwise we use only the virtio device > > (*). The important bit here is that we need to wait until the guest is > > booted, and the virtio-net driver is loaded, and then it tells us if it > > understands failover (or not). At that point we decide if we want to > > "really" create the primary. > > > > I know that it abuses device_add() as much as it can be, but I can't see > > any better way to handle it. We need to be able to "create" a device > > without showing it to the guest. And later, when we create a different > > device, and depending of driver support on the guest, we "finish" the > > creation of the primary device. > > > > Any good idea? Hm, the naive idea would be creating the device without attaching it to any bus. But I suppose qdev doesn't let you do that. Anyway, the part that I missed yesterday is that qdev_device_add() already skips creating the device if qdev_should_hide_device(), which explains how the inconsistency is created. (As an aside, it then returns NULL without setting an error to indicate success, which is an awkward interface, and sure enough, qmp_device_add() gets it wrong and deletes the QemuOpts again. So hotplugging the virtio-net standby device doesn't even seem to work?) Could we just save the configuration in the .hide_device callback (i.e. failover_hide_primary_device() in virtio-net) to a new field in VirtIONet and then use that when actually creating the device instead of accessing the command line state in the QemuOptsList? It seems that we can currently add two primary devices that are then both hidden. failover_add_primary() adds only one of them, leaving the other one hidden. Is this a bug and we should reject such a configuration or do we need to support keeping configurations for multiple primary devices in a single standby device? This would still be ugly because the configuration is only really validated when the primary device is actually added instead of immediately on -device/device_add, but at least it would keep the ugliness more local and wouldn't block the move away from QemuOpts (the config would just be stored as a QDict after my patches). > I don't know if it can help the discussion, but I'm reformatting the > failover code to move all the PCI stuff to pci files. > > And there is a lot of inconsistencies regarding the device_add and --device > option so I've been in the end to add a list of of hidden devices rather > than relying on the command line. > > See PATCH 8 of series "[RFC PATC
[libvirt PATCHv2 5/5] qemu: implement virtiofs hotunplug
Signed-off-by: Ján Tomko --- src/conf/domain_conf.c | 24 +++ src/conf/domain_conf.h | 2 + src/libvirt_private.syms | 1 + src/qemu/qemu_hotplug.c | 87 +++- 4 files changed, 112 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b8370f6950..057dbf91a5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -28829,6 +28829,30 @@ virDomainFSRemove(virDomainDef *def, size_t i) return fs; } +ssize_t +virDomainFSDefFind(virDomainDef *def, + virDomainFSDef *fs) +{ +size_t i = 0; + +for (i = 0; i < def->nfss; i++) { +virDomainFSDef *tmp = def->fss[i]; + +if (fs->dst && STRNEQ_NULLABLE(fs->dst, tmp->dst)) +continue; + +if (fs->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && +!virDomainDeviceInfoAddressIsEqual(&fs->info, &tmp->info)) +continue; + +if (fs->info.alias && STRNEQ_NULLABLE(fs->info.alias, tmp->info.alias)) +continue; + +return i; +} +return -1; +} + virDomainFSDef * virDomainGetFilesystemForTarget(virDomainDef *def, const char *target) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index c23c233184..1fcef7b0e1 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3757,6 +3757,8 @@ virDomainFSDef *virDomainGetFilesystemForTarget(virDomainDef *def, int virDomainFSInsert(virDomainDef *def, virDomainFSDef *fs); int virDomainFSIndexByName(virDomainDef *def, const char *name); virDomainFSDef *virDomainFSRemove(virDomainDef *def, size_t i); +ssize_t virDomainFSDefFind(virDomainDef *def, + virDomainFSDef *fs); unsigned int virDomainVideoDefaultRAM(const virDomainDef *def, const virDomainVideoType type); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fd0eea0777..687a3bbc4c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -410,6 +410,7 @@ virDomainFeatureTypeFromString; virDomainFeatureTypeToString; virDomainFSAccessModeTypeToString; virDomainFSCacheModeTypeToString; +virDomainFSDefFind; virDomainFSDefFree; virDomainFSDefNew; virDomainFSDriverTypeToString; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 73e5a39852..0947243c16 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -5183,6 +5183,51 @@ qemuDomainRemoveRedirdevDevice(virQEMUDriver *driver, } +static int +qemuDomainRemoveFSDevice(virQEMUDriver *driver, + virDomainObj *vm, + virDomainFSDef *fs) +{ +g_autofree char *charAlias = NULL; +qemuDomainObjPrivate *priv = vm->privateData; +ssize_t idx; +int rc = 0; + +VIR_DEBUG("Removing FS device %s from domain %p %s", + fs->info.alias, vm, vm->def->name); + +if (fs->fsdriver != VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) { +virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("only virtiofs filesystems can be hotplugged")); +return -1; +} + +charAlias = qemuDomainGetVhostUserChrAlias(fs->info.alias); + +qemuDomainObjEnterMonitor(driver, vm); + +if (qemuMonitorDetachCharDev(priv->mon, charAlias) < 0) +rc = -1; + +if (qemuDomainObjExitMonitor(driver, vm) < 0) +return -1; + +virDomainAuditFS(vm, fs, NULL, "detach", rc == 0); + +if (rc < 0) +return -1; + +if (!fs->sock) +qemuVirtioFSStop(driver, vm, fs); + +if ((idx = virDomainFSDefFind(vm->def, fs)) >= 0) +virDomainFSRemove(vm->def, idx); +qemuDomainReleaseDeviceAddress(vm, &fs->info); +virDomainFSDefFree(fs); +return 0; +} + + static void qemuDomainRemoveAuditDevice(virDomainObj *vm, virDomainDeviceDef *detach, @@ -5221,6 +5266,10 @@ qemuDomainRemoveAuditDevice(virDomainObj *vm, virDomainAuditRedirdev(vm, detach->data.redirdev, "detach", success); break; +case VIR_DOMAIN_DEVICE_FS: +virDomainAuditFS(vm, detach->data.fs, NULL, "detach", success); +break; + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_CONTROLLER: case VIR_DOMAIN_DEVICE_WATCHDOG: @@ -5228,7 +5277,6 @@ qemuDomainRemoveAuditDevice(virDomainObj *vm, /* These devices don't have associated audit logs */ break; -case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_GRAPHICS: @@ -5326,9 +5374,13 @@ qemuDomainRemoveDevice(virQEMUDriver *driver, return -1; break; +case VIR_DOMAIN_DEVICE_FS: +if (qemuDomainRemoveFSDevice(driver, vm, dev->data.fs) < 0) +return -1; +break; + case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_LEASE: -case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVI
[PATCH v3 5/5] qemu: add librbd encryption engine
rbd encryption is new in qemu 6.1.0. This commit adds a new encryption engine property which allows the user to use this new encryption engine. Signed-off-by: Or Ozeri --- docs/formatstorageencryption.html.in | 2 +- docs/schemas/storagecommon.rng| 1 + src/conf/storage_encryption_conf.c| 2 +- src/conf/storage_encryption_conf.h| 1 + src/qemu/qemu_block.c | 30 +++ src/qemu/qemu_domain.c| 24 ++ ...sk-network-rbd-encryption.x86_64-6.0.0.err | 1 + ...-network-rbd-encryption.x86_64-latest.args | 49 +++ .../disk-network-rbd-encryption.xml | 75 + tests/qemuxml2argvtest.c | 2 + ...k-network-rbd-encryption.x86_64-latest.xml | 83 +++ tests/qemuxml2xmltest.c | 1 + 12 files changed, 269 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/disk-network-rbd-encryption.x86_64-6.0.0.err create mode 100644 tests/qemuxml2argvdata/disk-network-rbd-encryption.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/disk-network-rbd-encryption.xml create mode 100644 tests/qemuxml2xmloutdata/disk-network-rbd-encryption.x86_64-latest.xml diff --git a/docs/formatstorageencryption.html.in b/docs/formatstorageencryption.html.in index 5783381a4a..31ec2698a1 100644 --- a/docs/formatstorageencryption.html.in +++ b/docs/formatstorageencryption.html.in @@ -27,7 +27,7 @@ The encryption tag supports an optional engine tag, which allows selecting which component actually handles the encryption. Currently defined values of engine are - qemu. + qemu and librbd. The encryption tag can currently contain a sequence of diff --git a/docs/schemas/storagecommon.rng b/docs/schemas/storagecommon.rng index b34577c582..591a158209 100644 --- a/docs/schemas/storagecommon.rng +++ b/docs/schemas/storagecommon.rng @@ -20,6 +20,7 @@ qemu +librbd diff --git a/src/conf/storage_encryption_conf.c b/src/conf/storage_encryption_conf.c index e8da02b605..2639b43119 100644 --- a/src/conf/storage_encryption_conf.c +++ b/src/conf/storage_encryption_conf.c @@ -49,7 +49,7 @@ VIR_ENUM_IMPL(virStorageEncryptionFormat, VIR_ENUM_IMPL(virStorageEncryptionEngine, VIR_STORAGE_ENCRYPTION_ENGINE_LAST, - "default", "qemu", + "default", "qemu", "librbd", ); static void diff --git a/src/conf/storage_encryption_conf.h b/src/conf/storage_encryption_conf.h index c722f832f5..2e6f9193bd 100644 --- a/src/conf/storage_encryption_conf.h +++ b/src/conf/storage_encryption_conf.h @@ -54,6 +54,7 @@ struct _virStorageEncryptionInfoDef { typedef enum { VIR_STORAGE_ENCRYPTION_ENGINE_DEFAULT = 0, VIR_STORAGE_ENCRYPTION_ENGINE_QEMU, +VIR_STORAGE_ENCRYPTION_ENGINE_LIBRBD, VIR_STORAGE_ENCRYPTION_ENGINE_LAST, } virStorageEncryptionEngineType; diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index a43831ce18..62c40d39d1 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -875,6 +875,8 @@ qemuBlockStorageSourceGetRBDProps(virStorageSource *src, qemuDomainStorageSourcePrivate *srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src); g_autoptr(virJSONValue) servers = NULL; virJSONValue *ret = NULL; +g_autoptr(virJSONValue) encrypt = NULL; +const char *encformat; const char *username = NULL; g_autoptr(virJSONValue) authmodes = NULL; g_autoptr(virJSONValue) mode = NULL; @@ -899,12 +901,40 @@ qemuBlockStorageSourceGetRBDProps(virStorageSource *src, return NULL; } +if (src->encryption && +src->encryption->engine == VIR_STORAGE_ENCRYPTION_ENGINE_LIBRBD) { +switch ((virStorageEncryptionFormatType) src->encryption->format) { +case VIR_STORAGE_ENCRYPTION_FORMAT_LUKS: +encformat = "luks"; +break; + +case VIR_STORAGE_ENCRYPTION_FORMAT_LUKS2: +encformat = "luks2"; +break; + +case VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT: +case VIR_STORAGE_ENCRYPTION_FORMAT_QCOW: +case VIR_STORAGE_ENCRYPTION_FORMAT_LAST: +default: +virReportEnumRangeError(virStorageEncryptionFormatType, +src->encryption->format); +return NULL; +} + +if (virJSONValueObjectCreate(&encrypt, + "s:format", encformat, + "s:key-secret", srcPriv->encinfo->alias, + NULL) < 0) +return NULL; +} + if (virJSONValueObjectCreate(&ret, "s:pool", src->volume, "s:image", src->path, "S:snap
[PATCH v3 3/5] conf: add luks2 encryption format
This commit extends libvirt XML configuration to support luks2 encryption format. This means that becomes valid. Actual handler (other than returning "not supported") for this new format will be added in an upcoming commit. Signed-off-by: Or Ozeri --- docs/formatstorageencryption.html.in | 2 +- docs/schemas/storagecommon.rng | 1 + src/conf/storage_encryption_conf.c | 2 +- src/conf/storage_encryption_conf.h | 1 + src/qemu/qemu_block.c| 1 + src/qemu/qemu_domain.c | 3 ++- 6 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/formatstorageencryption.html.in b/docs/formatstorageencryption.html.in index 7215c307d7..b2631ab25d 100644 --- a/docs/formatstorageencryption.html.in +++ b/docs/formatstorageencryption.html.in @@ -18,7 +18,7 @@ is encryption, with a mandatory attribute format. Currently defined values of format are default, qcow, - and luks. + luks, and luks2. Each value of format implies some expectations about the content of the encryption tag. Other format values may be defined in the future. diff --git a/docs/schemas/storagecommon.rng b/docs/schemas/storagecommon.rng index 9ebb27700d..7d1d066289 100644 --- a/docs/schemas/storagecommon.rng +++ b/docs/schemas/storagecommon.rng @@ -13,6 +13,7 @@ default qcow luks + luks2 diff --git a/src/conf/storage_encryption_conf.c b/src/conf/storage_encryption_conf.c index 9112b96cc7..2df4ec96af 100644 --- a/src/conf/storage_encryption_conf.c +++ b/src/conf/storage_encryption_conf.c @@ -44,7 +44,7 @@ VIR_ENUM_IMPL(virStorageEncryptionSecret, VIR_ENUM_IMPL(virStorageEncryptionFormat, VIR_STORAGE_ENCRYPTION_FORMAT_LAST, - "default", "qcow", "luks", + "default", "qcow", "luks", "luks2", ); static void diff --git a/src/conf/storage_encryption_conf.h b/src/conf/storage_encryption_conf.h index 34adbd5f7b..32e3a1243a 100644 --- a/src/conf/storage_encryption_conf.h +++ b/src/conf/storage_encryption_conf.h @@ -56,6 +56,7 @@ typedef enum { VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT = 0, VIR_STORAGE_ENCRYPTION_FORMAT_QCOW, /* Both qcow and qcow2 */ VIR_STORAGE_ENCRYPTION_FORMAT_LUKS, +VIR_STORAGE_ENCRYPTION_FORMAT_LUKS2, VIR_STORAGE_ENCRYPTION_FORMAT_LAST, } virStorageEncryptionFormatType; diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 393d3f44d7..31b6b3566b 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1328,6 +1328,7 @@ qemuBlockStorageSourceGetCryptoProps(virStorageSource *src, break; case VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT: +case VIR_STORAGE_ENCRYPTION_FORMAT_LUKS2: case VIR_STORAGE_ENCRYPTION_FORMAT_LAST: default: virReportEnumRangeError(virStorageEncryptionFormatType, diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 288a40bca6..cd65e8b365 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1228,7 +1228,8 @@ static bool qemuDomainDiskHasEncryptionSecret(virStorageSource *src) { if (!virStorageSourceIsEmpty(src) && src->encryption && -src->encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS && +(src->encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS || + src->encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS2) && src->encryption->nsecrets > 0) return true; -- 2.25.1
[PATCH v3 0/5] Add support for librbd encryption
v3: rebased on master v2: addressed (hopefully) all of Peter's v1 comments (thanks Peter!) Or Ozeri (5): qemu: add disk post parse to qemublocktest qemu: add rbd encryption capability probing conf: add luks2 encryption format conf: add encryption engine property qemu: add librbd encryption engine docs/formatstorageencryption.html.in | 8 +- docs/schemas/domainbackup.rng | 7 + docs/schemas/storagecommon.rng| 9 + src/conf/storage_encryption_conf.c| 33 +++- src/conf/storage_encryption_conf.h| 11 ++ src/qemu/qemu_block.c | 33 src/qemu/qemu_capabilities.c | 2 + src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_domain.c| 37 +++- src/qemu/qemu_domain.h| 3 + tests/qemublocktest.c | 3 + .../caps_6.1.0.x86_64.xml | 1 + tests/qemustatusxml2xmldata/upgrade-out.xml | 6 +- ...sk-network-rbd-encryption.x86_64-6.0.0.err | 1 + ...-network-rbd-encryption.x86_64-latest.args | 49 ++ .../disk-network-rbd-encryption.xml | 75 + tests/qemuxml2argvtest.c | 2 + ...k-network-rbd-encryption.x86_64-latest.xml | 83 + tests/qemuxml2xmloutdata/disk-nvme.xml| 65 ++- .../disk-slices.x86_64-latest.xml | 4 +- .../encrypted-disk-usage.xml | 38 - tests/qemuxml2xmloutdata/encrypted-disk.xml | 2 +- .../luks-disks-source-qcow2.x86_64-latest.xml | 14 +- .../qemuxml2xmloutdata/luks-disks-source.xml | 10 +- tests/qemuxml2xmloutdata/luks-disks.xml | 47 +- tests/qemuxml2xmloutdata/user-aliases.xml | 159 +- tests/qemuxml2xmltest.c | 1 + 27 files changed, 677 insertions(+), 27 deletions(-) create mode 100644 tests/qemuxml2argvdata/disk-network-rbd-encryption.x86_64-6.0.0.err create mode 100644 tests/qemuxml2argvdata/disk-network-rbd-encryption.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/disk-network-rbd-encryption.xml create mode 100644 tests/qemuxml2xmloutdata/disk-network-rbd-encryption.x86_64-latest.xml mode change 12 => 100644 tests/qemuxml2xmloutdata/disk-nvme.xml mode change 12 => 100644 tests/qemuxml2xmloutdata/encrypted-disk-usage.xml mode change 12 => 100644 tests/qemuxml2xmloutdata/luks-disks.xml mode change 12 => 100644 tests/qemuxml2xmloutdata/user-aliases.xml -- 2.25.1
[PATCH v3 1/5] qemu: add disk post parse to qemublocktest
The post parse callback is part of the real (non-test) processing flow. This commit adds it (for disks) to the qemublocktest flow as well. Specifically, this will be needed for tests that use luks encryption, so that the default encryption engine (which is added in an upcoming commit) will be overridden by qemu. Signed-off-by: Or Ozeri --- src/qemu/qemu_domain.c | 2 +- src/qemu/qemu_domain.h | 3 +++ tests/qemublocktest.c | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a755f8678e..288a40bca6 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5259,7 +5259,7 @@ qemuDomainDeviceDiskDefPostParseRestoreSecAlias(virDomainDiskDef *disk, } -static int +int qemuDomainDeviceDiskDefPostParse(virDomainDiskDef *disk, unsigned int parseFlags) { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 64f92988b7..0642e44fbc 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -872,6 +872,9 @@ int qemuDomainSecretPrepare(virQEMUDriver *driver, int qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk, virQEMUCaps *qemuCaps); +int qemuDomainDeviceDiskDefPostParse(virDomainDiskDef *disk, + unsigned int parseFlags); + int qemuDomainPrepareChannel(virDomainChrDef *chr, const char *domainChannelTargetDir) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 3e61e923a9..0e4bb146c9 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -276,6 +276,9 @@ testQemuDiskXMLToProps(const void *opaque) VIR_DOMAIN_DEF_PARSE_STATUS))) return -1; +if (qemuDomainDeviceDiskDefPostParse(disk, 0) < 0) +return -1; + if (!(vmdef = virDomainDefNew(data->driver->xmlopt))) return -1; -- 2.25.1
[libvirt PATCHv2 3/5] qemu: Revert "qemuExtDevicesStart: pass logManager"
This reverts commit b164eac5e1d4ebe17e673f0427b70f862a670f94 Signed-off-by: Ján Tomko --- src/qemu/qemu_extdevice.c | 1 - src/qemu/qemu_extdevice.h | 1 - src/qemu/qemu_process.c | 4 +--- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index 3c34bb8321..537b130394 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -166,7 +166,6 @@ qemuExtDevicesCleanupHost(virQEMUDriver *driver, int qemuExtDevicesStart(virQEMUDriver *driver, virDomainObj *vm, -virLogManager *logManager G_GNUC_UNUSED, bool incomingMigration) { virDomainDef *def = vm->def; diff --git a/src/qemu/qemu_extdevice.h b/src/qemu/qemu_extdevice.h index 5f638438a8..43d2a4dfff 100644 --- a/src/qemu/qemu_extdevice.h +++ b/src/qemu/qemu_extdevice.h @@ -46,7 +46,6 @@ void qemuExtDevicesCleanupHost(virQEMUDriver *driver, int qemuExtDevicesStart(virQEMUDriver *driver, virDomainObj *vm, -virLogManager *logManager, bool incomingMigration) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 1d0165af6d..96b7d1edc7 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7238,9 +7238,7 @@ qemuProcessLaunch(virConnectPtr conn, if (qemuProcessGenID(vm, flags) < 0) goto cleanup; -if (qemuExtDevicesStart(driver, vm, -qemuDomainLogContextGetManager(logCtxt), -incoming != NULL) < 0) +if (qemuExtDevicesStart(driver, vm, incoming != NULL) < 0) goto cleanup; VIR_DEBUG("Building emulator command line"); -- 2.31.1
[libvirt PATCHv2 4/5] qemu: implement virtiofs hotplug
https://bugzilla.redhat.com/show_bug.cgi?id=1897708 Signed-off-by: Ján Tomko --- src/qemu/qemu_driver.c | 9 +++- src/qemu/qemu_hotplug.c | 99 + 2 files changed, 107 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 760d30a867..65b2ef8e86 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6945,8 +6945,15 @@ qemuDomainAttachDeviceLive(virDomainObj *vm, } break; -case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_FS: +ret = qemuDomainAttachFSDevice(driver, vm, dev->data.fs); +if (ret == 0) { +alias = dev->data.fs->info.alias; +dev->data.fs = NULL; +} +break; + +case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_GRAPHICS: diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 22239b2689..73e5a39852 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -35,6 +35,7 @@ #include "qemu_security.h" #include "qemu_block.h" #include "qemu_snapshot.h" +#include "qemu_virtiofs.h" #include "domain_audit.h" #include "netdev_bandwidth_conf.h" #include "domain_nwfilter.h" @@ -3396,6 +3397,104 @@ qemuDomainAttachVsockDevice(virQEMUDriver *driver, } +int +qemuDomainAttachFSDevice(virQEMUDriver *driver, + virDomainObj *vm, + virDomainFSDef *fs) +{ +qemuDomainObjPrivate *priv = vm->privateData; +virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_FS, + { .fs = fs } }; +g_autoptr(virDomainChrSourceDef) chardev = NULL; +virErrorPtr origErr = NULL; +bool releaseaddr = false; +bool chardevAdded = false; +bool started = false; +g_autofree char *devstr = NULL; +g_autofree char *charAlias = NULL; +int ret = -1; + +if (fs->fsdriver != VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) { +virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("only virtiofs filesystems can be hotplugged")); +return -1; +} + +if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev) < 0) +return -1; + +if (qemuAssignDeviceFSAlias(vm->def, fs) < 0) +goto cleanup; + +chardev = virDomainChrSourceDefNew(priv->driver->xmlopt); +chardev->type = VIR_DOMAIN_CHR_TYPE_UNIX; +chardev->data.nix.path = qemuDomainGetVHostUserFSSocketPath(priv, fs); + +charAlias = qemuDomainGetVhostUserChrAlias(fs->info.alias); + +if (!(devstr = qemuBuildVHostUserFsDevStr(fs, vm->def, charAlias, priv))) +goto cleanup; + +if (!fs->sock) { +if (qemuVirtioFSPrepareDomain(driver, fs) < 0) +goto cleanup; + +if (qemuVirtioFSStart(driver, vm, fs) < 0) +goto cleanup; +started = true; + +if (qemuVirtioFSSetupCgroup(vm, fs, priv->cgroup) < 0) +goto cleanup; +} + +qemuDomainObjEnterMonitor(driver, vm); + +if (qemuMonitorAttachCharDev(priv->mon, charAlias, chardev) < 0) +goto exit_monitor; +chardevAdded = true; + +if (qemuDomainAttachExtensionDevice(priv->mon, &fs->info) < 0) +goto exit_monitor; + +if (qemuMonitorAddDevice(priv->mon, devstr) < 0) { +ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &fs->info)); +goto exit_monitor; +} + +if (qemuDomainObjExitMonitor(driver, vm) < 0) { +releaseaddr = false; +goto cleanup; +} + +VIR_APPEND_ELEMENT_COPY(vm->def->fss, vm->def->nfss, fs); + +ret = 0; + + audit: +virDomainAuditFS(vm, NULL, fs, "attach", ret == 0); + cleanup: +if (ret < 0) { +virErrorPreserveLast(&origErr); +if (releaseaddr) +qemuDomainReleaseDeviceAddress(vm, &fs->info); +if (started) +qemuVirtioFSStop(driver, vm, fs); +virErrorRestore(&origErr); +} + +return ret; + + exit_monitor: +virErrorPreserveLast(&origErr); +if (chardevAdded) +ignore_value(qemuMonitorDetachCharDev(priv->mon, charAlias)); +if (qemuDomainObjExitMonitor(driver, vm) < 0) +releaseaddr = false; +virErrorRestore(&origErr); +goto audit; +} + + int qemuDomainAttachLease(virQEMUDriver *driver, virDomainObj *vm, -- 2.31.1
[libvirt PATCHv2 2/5] qemu: virtiofs: open a separate connection to virtlogd
Do not depend on passing a logManager. Create a new connection. Signed-off-by: Ján Tomko --- src/qemu/qemu_extdevice.c | 4 ++-- src/qemu/qemu_virtiofs.c | 8 ++-- src/qemu/qemu_virtiofs.h | 3 +-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index ef0b3f1981..3c34bb8321 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -166,7 +166,7 @@ qemuExtDevicesCleanupHost(virQEMUDriver *driver, int qemuExtDevicesStart(virQEMUDriver *driver, virDomainObj *vm, -virLogManager *logManager, +virLogManager *logManager G_GNUC_UNUSED, bool incomingMigration) { virDomainDef *def = vm->def; @@ -197,7 +197,7 @@ qemuExtDevicesStart(virQEMUDriver *driver, virDomainFSDef *fs = def->fss[i]; if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS && !fs->sock) { -if (qemuVirtioFSStart(logManager, driver, vm, fs) < 0) +if (qemuVirtioFSStart(driver, vm, fs) < 0) return -1; } } diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c index 08a8b4ed42..3ca45457c1 100644 --- a/src/qemu/qemu_virtiofs.c +++ b/src/qemu/qemu_virtiofs.c @@ -157,8 +157,7 @@ qemuVirtioFSBuildCommandLine(virQEMUDriverConfig *cfg, } int -qemuVirtioFSStart(virLogManager *logManager, - virQEMUDriver *driver, +qemuVirtioFSStart(virQEMUDriver *driver, virDomainObj *vm, virDomainFSDef *fs) { @@ -191,6 +190,11 @@ qemuVirtioFSStart(virLogManager *logManager, logpath = qemuVirtioFSCreateLogFilename(cfg, vm->def, fs->info.alias); if (cfg->stdioLogD) { +g_autoptr(virLogManager) logManager = virLogManagerNew(driver->privileged); + +if (!logManager) +goto cleanup; + if ((logfd = virLogManagerDomainOpenLogFile(logManager, "qemu", vm->def->uuid, diff --git a/src/qemu/qemu_virtiofs.h b/src/qemu/qemu_virtiofs.h index 1886339394..5463acef98 100644 --- a/src/qemu/qemu_virtiofs.h +++ b/src/qemu/qemu_virtiofs.h @@ -27,8 +27,7 @@ qemuVirtioFSCreateSocketFilename(virDomainObj *vm, const char *alias); int -qemuVirtioFSStart(virLogManager *logManager, - virQEMUDriver *driver, +qemuVirtioFSStart(virQEMUDriver *driver, virDomainObj *vm, virDomainFSDef *fs); void -- 2.31.1
[PATCH v3 2/5] qemu: add rbd encryption capability probing
rbd encryption is new in qemu 6.1.0. This commit adds capability probing for it. Signed-off-by: Or Ozeri --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml | 1 + 3 files changed, 4 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 82687dbf39..ea0734db15 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -644,6 +644,7 @@ VIR_ENUM_IMPL(virQEMUCaps, "virtio-mem-pci", /* QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI */ "memory-backend-file.reserve", /* QEMU_CAPS_MEMORY_BACKEND_RESERVE */ "piix4.acpi-root-pci-hotplug", /* QEMU_CAPS_PIIX4_ACPI_ROOT_PCI_HOTPLUG */ + "rbd-encryption", /* QEMU_CAPS_RBD_ENCRYPTION */ ); @@ -1565,6 +1566,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsQMPSchemaQueries[] = { { "blockdev-add/arg-type/+file/$dynamic-auto-read-only", QEMU_CAPS_BLOCK_FILE_AUTO_READONLY_DYNAMIC }, { "blockdev-add/arg-type/+nvme", QEMU_CAPS_DRIVE_NVME }, { "blockdev-add/arg-type/+file/aio/^io_uring", QEMU_CAPS_AIO_IO_URING }, +{ "blockdev-add/arg-type/+rbd/encrypt", QEMU_CAPS_RBD_ENCRYPTION }, { "blockdev-add/arg-type/discard", QEMU_CAPS_DRIVE_DISCARD }, { "blockdev-add/arg-type/detect-zeroes", QEMU_CAPS_DRIVE_DETECT_ZEROES }, { "blockdev-backup", QEMU_CAPS_BLOCKDEV_BACKUP }, diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 2bbfc15dc4..674da98539 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -624,6 +624,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI, /* -device virtio-mem-pci */ QEMU_CAPS_MEMORY_BACKEND_RESERVE, /* -object memory-backend-*.reserve= */ QEMU_CAPS_PIIX4_ACPI_ROOT_PCI_HOTPLUG, /* -M pc PIIX4_PM.acpi-root-pci-hotplug */ +QEMU_CAPS_RBD_ENCRYPTION, /* Ceph RBD encryption support */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml index 87b37a2b7c..8180cfd6c2 100644 --- a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml @@ -243,6 +243,7 @@ + 6001000 0 43100243 -- 2.25.1
[libvirt PATCHv2 1/5] logging: define cleanup func for virLogManager
Signed-off-by: Ján Tomko --- src/logging/log_manager.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/logging/log_manager.h b/src/logging/log_manager.h index 9a8f9b6af8..80f14934d7 100644 --- a/src/logging/log_manager.h +++ b/src/logging/log_manager.h @@ -27,6 +27,8 @@ typedef struct _virLogManager virLogManager; virLogManager *virLogManagerNew(bool privileged); void virLogManagerFree(virLogManager *mgr); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virLogManager, virLogManagerFree); + int virLogManagerDomainOpenLogFile(virLogManager *mgr, const char *driver, -- 2.31.1
[libvirt PATCHv2 0/5] qemu: implement virtiofs hot(un)plug (virtiofs epopee)
diff to v1 * do not store logCtxt in private data * qemuDomainGetVHostUserChrSourceDef inlined in the only function that uses it * a new connection to the logManager is opened when virtiofsd is started * use VIR_APPEND_ELEMENT_COPY to reuse 'fs' on the successful audit * qemuDomainRemoveFSDevice only processes virtiofs devices now Ján Tomko (5): logging: define cleanup func for virLogManager qemu: virtiofs: open a separate connection to virtlogd qemu: Revert "qemuExtDevicesStart: pass logManager" qemu: implement virtiofs hotplug qemu: implement virtiofs hotunplug src/conf/domain_conf.c| 24 + src/conf/domain_conf.h| 2 + src/libvirt_private.syms | 1 + src/logging/log_manager.h | 2 + src/qemu/qemu_driver.c| 9 +- src/qemu/qemu_extdevice.c | 3 +- src/qemu/qemu_extdevice.h | 1 - src/qemu/qemu_hotplug.c | 186 +- src/qemu/qemu_process.c | 4 +- src/qemu/qemu_virtiofs.c | 8 +- src/qemu/qemu_virtiofs.h | 3 +- 11 files changed, 230 insertions(+), 13 deletions(-) -- 2.31.1
[PATCH v3 4/5] conf: add encryption engine property
This commit extends libvirt XML configuration to support a custom encryption engine. This means that becomes valid. The only engine for now is qemu. However, a new engine (librbd) will be added in an upcoming commit. If no engine is specified, qemu will be used (assuming qemu driver is used). Signed-off-by: Or Ozeri --- docs/formatstorageencryption.html.in | 6 + docs/schemas/domainbackup.rng | 7 + docs/schemas/storagecommon.rng| 7 + src/conf/storage_encryption_conf.c| 31 +++- src/conf/storage_encryption_conf.h| 9 + src/qemu/qemu_block.c | 2 + src/qemu/qemu_domain.c| 8 + tests/qemustatusxml2xmldata/upgrade-out.xml | 6 +- tests/qemuxml2xmloutdata/disk-nvme.xml| 65 ++- .../disk-slices.x86_64-latest.xml | 4 +- .../encrypted-disk-usage.xml | 38 - tests/qemuxml2xmloutdata/encrypted-disk.xml | 2 +- .../luks-disks-source-qcow2.x86_64-latest.xml | 14 +- .../qemuxml2xmloutdata/luks-disks-source.xml | 10 +- tests/qemuxml2xmloutdata/luks-disks.xml | 47 +- tests/qemuxml2xmloutdata/user-aliases.xml | 159 +- 16 files changed, 392 insertions(+), 23 deletions(-) mode change 12 => 100644 tests/qemuxml2xmloutdata/disk-nvme.xml mode change 12 => 100644 tests/qemuxml2xmloutdata/encrypted-disk-usage.xml mode change 12 => 100644 tests/qemuxml2xmloutdata/luks-disks.xml mode change 12 => 100644 tests/qemuxml2xmloutdata/user-aliases.xml diff --git a/docs/formatstorageencryption.html.in b/docs/formatstorageencryption.html.in index b2631ab25d..5783381a4a 100644 --- a/docs/formatstorageencryption.html.in +++ b/docs/formatstorageencryption.html.in @@ -23,6 +23,12 @@ content of the encryption tag. Other format values may be defined in the future. + + The encryption tag supports an optional engine + tag, which allows selecting which component actually handles + the encryption. Currently defined values of engine are + qemu. + The encryption tag can currently contain a sequence of secret tags, each with mandatory attributes type diff --git a/docs/schemas/domainbackup.rng b/docs/schemas/domainbackup.rng index c03455a5a7..05cc28ab00 100644 --- a/docs/schemas/domainbackup.rng +++ b/docs/schemas/domainbackup.rng @@ -14,6 +14,13 @@ luks + + + +qemu + + + diff --git a/docs/schemas/storagecommon.rng b/docs/schemas/storagecommon.rng index 7d1d066289..b34577c582 100644 --- a/docs/schemas/storagecommon.rng +++ b/docs/schemas/storagecommon.rng @@ -16,6 +16,13 @@ luks2 + + + +qemu + + + diff --git a/src/conf/storage_encryption_conf.c b/src/conf/storage_encryption_conf.c index 2df4ec96af..e8da02b605 100644 --- a/src/conf/storage_encryption_conf.c +++ b/src/conf/storage_encryption_conf.c @@ -47,6 +47,11 @@ VIR_ENUM_IMPL(virStorageEncryptionFormat, "default", "qcow", "luks", "luks2", ); +VIR_ENUM_IMPL(virStorageEncryptionEngine, + VIR_STORAGE_ENCRYPTION_ENGINE_LAST, + "default", "qemu", +); + static void virStorageEncryptionInfoDefClear(virStorageEncryptionInfoDef *def) { @@ -120,6 +125,7 @@ virStorageEncryptionCopy(const virStorageEncryption *src) ret->secrets = g_new0(virStorageEncryptionSecret *, src->nsecrets); ret->nsecrets = src->nsecrets; ret->format = src->format; +ret->engine = src->engine; for (i = 0; i < src->nsecrets; i++) { if (!(ret->secrets[i] = virStorageEncryptionSecretCopy(src->secrets[i]))) @@ -217,6 +223,7 @@ virStorageEncryptionParseNode(xmlNodePtr node, xmlNodePtr *nodes = NULL; virStorageEncryption *encdef = NULL; virStorageEncryption *ret = NULL; +g_autofree char *engine_str = NULL; g_autofree char *format_str = NULL; int n; size_t i; @@ -239,6 +246,16 @@ virStorageEncryptionParseNode(xmlNodePtr node, goto cleanup; } +if ((engine_str = virXPathString("string(./@engine)", ctxt))) { +if ((encdef->engine = + virStorageEncryptionEngineTypeFromString(engine_str)) < 0) { +virReportError(VIR_ERR_XML_ERROR, + _("unknown volume encryption engine type %s"), + engine_str); +goto cleanup; +} +} + if ((n = virXPathNodeSet("./secret", ctxt, &nodes)) < 0) goto cleanup; @@ -327,6 +344,7 @@ int virStorageEncryptionFormat(virBuffer *buf, virStorageEncryption *enc) { +const char *engine; const char *format; size_t i; @@ -335,7 +353,18 @@ virStorageEncryptionFormat(virBuffer *buf,
Re: [PATCH v2 1/5] qemu: add disk post parse to qemublocktest
On Wed, Oct 06, 2021 at 09:55:10 +, Or Ozeri wrote: >My commit which adds the encryption engine configuration is default to >"default". >Only in the post-parse callback in the qemu driver, I switch it from >"default" to "qemu". >Thus, if you don't call the post-parse on this test, then tests which use >luks format fail. >Specifically: >network-qcow2-backing-chain-encryption_auth >file-qcow2-backing-chain-encryption >file-raw-luks Yeah, that is okay. As noted in another reply please mention it in the commit message, because otherwise it seems a bit misplaced. Specifically exporting just a bit of the post-parse callbacks is questionable but okay in this case. And please post a rebased version as noted elsewhere.
RE: [PATCH v2 1/5] qemu: add disk post parse to qemublocktest
My commit which adds the encryption engine configuration is default to "default".Only in the post-parse callback in the qemu driver, I switch it from "default" to "qemu".Thus, if you don't call the post-parse on this test, then tests which use luks format fail.Specifically:network-qcow2-backing-chain-encryption_authfile-qcow2-backing-chain-encryptionfile-raw-luks-"Peter Krempa"wrote: -To: "Or Ozeri" From: "Peter Krempa" Date: 10/06/2021 09:37AMCc: libvir-list@redhat.com, idryo...@gmail.com, to.my.troc...@gmail.com, dan...@il.ibm.comSubject: [EXTERNAL] Re: [PATCH v2 1/5] qemu: add disk post parse to qemublocktestOn Tue, Oct 05, 2021 at 09:41:12 -0500, Or Ozeri wrote:> The post parse callback is part of the real (non-test) processing flow.> This commit adds it (for disks) to the qemublocktest flow as well.Could you please elaborate why this is needed? Specificallyqemublocktest takes a few liberties from the "real" code flow since weneed to fake a lot of stuff. E.g. see testQemuDiskXMLToJSONFakeSecrets.Specifically I didn't see anything in your patches [1] which would addanything to the post parse callback.[1] Well after my crude rebase of the series. What you've posted didn'tapply neither on master nor on the last release. I had to go one versionback and it had conflicts which I didn't spend much time thinking about.
Re: [PATCH 09/11] qdev: Avoid QemuOpts in QMP device_add
On 06/10/2021 10:21, Juan Quintela wrote: Kevin Wolf wrote: Am 05.10.2021 um 17:52 hat Damien Hedde geschrieben: Hi Usage - The primary device can be hotplugged or be part of the startup configuration -device virtio-net-pci,netdev=hostnet1,id=net1, mac=52:54:00:6f:55:cc,bus=root2,failover=on With the parameter failover=on the VIRTIO_NET_F_STANDBY feature will be enabled. -device vfio-pci,host=5e:00.2,id=hostdev0,bus=root1, failover_pair_id=net1 failover_pair_id references the id of the virtio-net standby device. This is only for pairing the devices within QEMU. The guest kernel module net_failover will match devices with identical MAC addresses. Hotplug --- Both primary and standby device can be hotplugged via the QEMU monitor. Note that if the virtio-net device is plugged first a warning will be issued that it couldn't find the primary device. So maybe this whole primary device lookup can happen during the -device CLI option creation loop. And we can indeed have un-created devices still in the list ? Yes, that's the only case for which I could imagine for an inconsistency between the qdev tree and QemuOpts, but failover_add_primary() is only called after feature negotiation with the guest driver, so we can be sure that the -device loop has completed long ago. And even if it hadn't completed yet, the paragraph also says that even hotplugging the device later is supported, so creating devices in the wrong order should still succeed. I hope that some of the people I added to CC have some more hints. Failover is ... interesting. You have two devices: primary and seconday. seconday is virtio-net, primary can be vfio and some other emulated devices. In the command line, devices can appear on any order, primary then secondary, secondary then primary, or only one of them. You can add (any of them) later in the toplevel. And now, what all this mess is about. We only enable the primary if the guest knows about failover. Otherwise we use only the virtio device (*). The important bit here is that we need to wait until the guest is booted, and the virtio-net driver is loaded, and then it tells us if it understands failover (or not). At that point we decide if we want to "really" create the primary. I know that it abuses device_add() as much as it can be, but I can't see any better way to handle it. We need to be able to "create" a device without showing it to the guest. And later, when we create a different device, and depending of driver support on the guest, we "finish" the creation of the primary device. Any good idea? I don't know if it can help the discussion, but I'm reformatting the failover code to move all the PCI stuff to pci files. And there is a lot of inconsistencies regarding the device_add and --device option so I've been in the end to add a list of of hidden devices rather than relying on the command line. See PATCH 8 of series "[RFC PATCH v2 0/8] virtio-net failover cleanup and new features" https://patchew.org/QEMU/20210820142002.152994-1-lviv...@redhat.com/ Thanks, Laurent
[PATCH] tools: Fix typo firemare -> firmware
Signed-off-by: Andrea Bolognani --- Pushed as trivial. tools/virt-host-validate-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c index 556223242d..7a5cda4104 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -515,7 +515,7 @@ int virHostValidateSecureGuests(const char *hvname, } else { virHostMsgFail(level, "AMD Secure Encrypted Virtualization appears to be " - "disabled in firemare."); + "disabled in firmware."); return VIR_HOST_VALIDATE_FAILURE(level); } } -- 2.31.1
Re: [libvirt PATCH 16/16] qemu: implement virtiofs hotunplug
On Wed, Oct 06, 2021 at 09:15:22 +0200, Ján Tomko wrote: > Signed-off-by: Ján Tomko > --- > src/conf/domain_conf.c | 24 > src/conf/domain_conf.h | 2 + > src/libvirt_private.syms | 1 + > src/qemu/qemu_hotplug.c | 81 +++- > 4 files changed, 106 insertions(+), 2 deletions(-) [...] > diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c > index f5dad0b829..713da5ebfc 100644 > --- a/src/qemu/qemu_hotplug.c > +++ b/src/qemu/qemu_hotplug.c > @@ -5180,6 +5180,45 @@ qemuDomainRemoveRedirdevDevice(virQEMUDriver *driver, > } > > > +static int > +qemuDomainRemoveFSDevice(virQEMUDriver *driver, > + virDomainObj *vm, > + virDomainFSDef *fs) > +{ > +g_autofree char *charAlias = NULL; > +qemuDomainObjPrivate *priv = vm->privateData; > +ssize_t idx; > +int rc = 0; > + > +VIR_DEBUG("Removing FS device %s from domain %p %s", > + fs->info.alias, vm, vm->def->name); > + > +charAlias = qemuDomainGetVhostUserChrAlias(fs->info.alias); > + > +qemuDomainObjEnterMonitor(driver, vm); > + > +if (qemuMonitorDetachCharDev(priv->mon, charAlias) < 0) > +rc = -1; Note that you must not assume here that the check below [1] that allows only virtio-fs device unplug guards this code too. The *Remove* code is executed always when we get a 'DEVICE_DELETED' event from qemu thus also for guest-initiated unplug, which theoretically can happen also for p9fs device. > + > +if (qemuDomainObjExitMonitor(driver, vm) < 0) > +return -1; > + > +virDomainAuditFS(vm, fs, NULL, "detach", rc == 0); > + > +if (rc < 0) > +return -1; > + > +if (!fs->sock) > +qemuVirtioFSStop(driver, vm, fs); > + > +if ((idx = virDomainFSDefFind(vm->def, fs)) >= 0) > +virDomainFSRemove(vm->def, idx); > +qemuDomainReleaseDeviceAddress(vm, &fs->info); > +virDomainFSDefFree(fs); > +return 0; > +} > + > + > static void > qemuDomainRemoveAuditDevice(virDomainObj *vm, > virDomainDeviceDef *detach, [...] > @@ -6020,6 +6066,31 @@ qemuDomainDetachPrepVsock(virDomainObj *vm, > } > > > +static int > +qemuDomainDetachPrepFS(virDomainObj *vm, > + virDomainFSDef *match, > + virDomainFSDef **detach) > +{ > +ssize_t idx; > + > +if ((idx = virDomainFSDefFind(vm->def, match)) < 0) { > +virReportError(VIR_ERR_DEVICE_MISSING, "%s", > + _("matching filesystem not found")); > +return -1; > +} > + > +if (vm->def->fss[idx]->fsdriver != VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) { > +virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", > + _("only virtiofs filesystems can be hotplugged")); > +return -1; > +} [1]. This check only guards host-initiated delete. > + > +*detach = vm->def->fss[idx]; > + > +return 0; > +} > + > + > static int > qemuDomainDetachDeviceLease(virQEMUDriver *driver, > virDomainObj *vm,
Re: [PATCH] tools: Fix virt-host-validate SEV detection
On Tue, Oct 05, 2021 at 10:41:47PM -0600, Jim Fehlig wrote: > virt-host-validate checks if AMD SEV is enabled by verifying > /sys/module/kvm_amd/parameters/sev is set to '1'. On a system > running kernel 5.13, the parameter is reported as 'Y'. To be > extra paranoid, add a check for 'y' along with 'Y' to complement > the existing check for '1'. > > Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1188715 > > Signed-off-by: Jim Fehlig > --- > tools/virt-host-validate-common.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Reviewed-by: Andrea Bolognani -- Andrea Bolognani / Red Hat / Virtualization
Re: [libvirt PATCH 15/16] qemu: implement virtiofs hotplug
On Wed, Oct 06, 2021 at 09:15:21 +0200, Ján Tomko wrote: > https://bugzilla.redhat.com/show_bug.cgi?id=1897708 > > Signed-off-by: Ján Tomko > --- > src/qemu/qemu_driver.c | 9 +++- > src/qemu/qemu_hotplug.c | 96 + > 2 files changed, 104 insertions(+), 1 deletion(-) > [...] > diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c > index 22239b2689..f5dad0b829 100644 > --- a/src/qemu/qemu_hotplug.c > +++ b/src/qemu/qemu_hotplug.c [...] > @@ -3396,6 +3397,101 @@ qemuDomainAttachVsockDevice(virQEMUDriver *driver, > } > > > +int > +qemuDomainAttachFSDevice(virQEMUDriver *driver, > + virDomainObj *vm, > + virDomainFSDef *fs) > +{ > +qemuDomainObjPrivate *priv = vm->privateData; > +virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_FS, > + { .fs = fs } }; > +g_autoptr(virDomainChrSourceDef) chardev = NULL; > +virErrorPtr origErr = NULL; > +bool releaseaddr = false; > +bool chardevAdded = false; > +bool started = false; > +g_autofree char *devstr = NULL; > +g_autofree char *charAlias = NULL; > +int ret = -1; > + > +if (fs->fsdriver != VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) { > +virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", > + _("only virtiofs filesystems can be hotplugged")); > +return -1; > +} > + > +if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev) < 0) > +return -1; > + > +if (qemuAssignDeviceFSAlias(vm->def, fs) < 0) > +goto cleanup; > + > +chardev = qemuDomainGetVHostUserChrSourceDef(priv, fs); > +charAlias = qemuDomainGetVhostUserChrAlias(fs->info.alias); > + > +if (!(devstr = qemuBuildVHostUserFsDevStr(fs, vm->def, charAlias, priv))) > +goto cleanup; > + > +if (!fs->sock) { > +if (qemuVirtioFSPrepareDomain(driver, fs) < 0) > +goto cleanup; > + > +if (qemuVirtioFSStart(qemuDomainLogContextGetManager(priv->logCtxt), > driver, vm, fs) < 0) > +goto cleanup; > +started = true; As noted, this won't work after restart of libvirtd. > + > +if (qemuVirtioFSSetupCgroup(vm, fs, priv->cgroup) < 0) > +goto cleanup; > +} > + > +qemuDomainObjEnterMonitor(driver, vm); > + > +if (qemuMonitorAttachCharDev(priv->mon, charAlias, chardev) < 0) > +goto exit_monitor; > +chardevAdded = true; > + > +if (qemuDomainAttachExtensionDevice(priv->mon, &fs->info) < 0) > +goto exit_monitor; > + > +if (qemuMonitorAddDevice(priv->mon, devstr) < 0) { > +ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &fs->info)); > +goto exit_monitor; > +} > + > +if (qemuDomainObjExitMonitor(driver, vm) < 0) { > +releaseaddr = false; > +goto cleanup; > +} > + > +VIR_APPEND_ELEMENT(vm->def->fss, vm->def->nfss, fs); This clears 'fs' ... > + > +ret = 0; > + > + audit: > +virDomainAuditFS(vm, NULL, fs, "attach", ret == 0); ... but you reference it here. > + cleanup: > +if (ret < 0) { > +virErrorPreserveLast(&origErr); > +if (releaseaddr) > +qemuDomainReleaseDeviceAddress(vm, &fs->info); > +if (started) > +qemuVirtioFSStop(driver, vm, fs); > +virErrorRestore(&origErr); > +} > + > +return ret; > + > + exit_monitor: > +virErrorPreserveLast(&origErr); > +if (chardevAdded) > +ignore_value(qemuMonitorDetachCharDev(priv->mon, charAlias)); > +if (qemuDomainObjExitMonitor(driver, vm) < 0) > +releaseaddr = false; > +virErrorRestore(&origErr); > +goto audit; > +}
Re: [libvirt PATCH 13/16] qemu: store logCtxt in domain private data
On Wed, Oct 06, 2021 at 09:15:19 +0200, Ján Tomko wrote: > We might need it later for device hotplug. > > Signed-off-by: Ján Tomko > --- > src/qemu/qemu_domain.h | 11 +++ > src/qemu/qemu_process.c | 5 - > 2 files changed, 11 insertions(+), 5 deletions(-) So from the code it looks like we will keep a connection to virtlogd open for the lifetime of the VM rather than we do now for the startup of the VM. The commit message doesn't justify or mention this and that is IMO a substantial change which could have consequences. Additionally there's no code whic would re-create the context on libvirtd restart, so even the 'might need it later for device hotplug' would not work properly.
Re: [libvirt PATCH 14/16] qemu: use priv->logCtxt in qemuProcessLaunch
On Wed, Oct 06, 2021 at 09:15:20 +0200, Ján Tomko wrote: > Remove the local variable in favor of the one stored in priv. > > Signed-off-by: Ján Tomko > --- > src/qemu/qemu_process.c | 20 +--- > 1 file changed, 9 insertions(+), 11 deletions(-) > > diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c > index 4a1fd753ee..17435c0ee9 100644 > --- a/src/qemu/qemu_process.c > +++ b/src/qemu/qemu_process.c [...] > @@ -7228,25 +7227,24 @@ qemuProcessLaunch(virConnectPtr conn, > hookData.cfg = cfg; > > VIR_DEBUG("Creating domain log file"); > -if (!(logCtxt = qemuDomainLogContextNew(driver, vm, > +if (!(priv->logCtxt = qemuDomainLogContextNew(driver, vm, > > QEMU_DOMAIN_LOG_CONTEXT_MODE_START))) {a Broken indentation.
[PATCH] tools: Fix virt-host-validate SEV detection
virt-host-validate checks if AMD SEV is enabled by verifying /sys/module/kvm_amd/parameters/sev is set to '1'. On a system running kernel 5.13, the parameter is reported as 'Y'. To be extra paranoid, add a check for 'y' along with 'Y' to complement the existing check for '1'. Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1188715 Signed-off-by: Jim Fehlig --- tools/virt-host-validate-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c index 556223242d..ba7f54b4ce 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -501,7 +501,7 @@ int virHostValidateSecureGuests(const char *hvname, return VIR_HOST_VALIDATE_FAILURE(level); } -if (mod_value[0] != '1') { +if (mod_value[0] != '1' && mod_value[0] != 'Y' && mod_value[0] != 'y') { virHostMsgFail(level, "AMD Secure Encrypted Virtualization appears to be " "disabled in kernel. Add kvm_amd.sev=1 " -- 2.33.0
Re: [libvirt PATCH 14/16] qemu: use priv->logCtxt in qemuProcessLaunch
On Wed, Oct 06, 2021 at 09:15:20 +0200, Ján Tomko wrote: > Remove the local variable in favor of the one stored in priv. > > Signed-off-by: Ján Tomko > --- > src/qemu/qemu_process.c | 20 +--- > 1 file changed, 9 insertions(+), 11 deletions(-) > > diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c > index 4a1fd753ee..17435c0ee9 100644 > --- a/src/qemu/qemu_process.c > +++ b/src/qemu/qemu_process.c [...] > > if (qemuProcessGenID(vm, flags) < 0) > goto cleanup; > > if (qemuExtDevicesStart(driver, vm, > -qemuDomainLogContextGetManager(logCtxt), > +qemuDomainLogContextGetManager(priv->logCtxt), I'm not a fan of making all the supporting processes log into the same log file ... > incoming != NULL) < 0) > goto cleanup; > > VIR_DEBUG("Building emulator command line"); > if (!(cmd = qemuBuildCommandLine(driver, > - qemuDomainLogContextGetManager(logCtxt), > + > qemuDomainLogContextGetManager(priv->logCtxt), > driver->securityManager, > vm, .. as qemu itself, but this is prior art. > incoming ? incoming->launchURI : NULL, Reviewed-by: Peter Krempa
Re: [libvirt PATCH 10/16] qemu: alias: prepare qemuAssignDeviceFSAlias for disjunct ranges
On Wed, Oct 06, 2021 at 10:27:48 +0200, Ján Tomko wrote: > On a Wednesday in 2021, Peter Krempa wrote: > > On Wed, Oct 06, 2021 at 09:15:16 +0200, Ján Tomko wrote: > > > Iterate through the array to find the first free index. > > > > > > Signed-off-by: Ján Tomko > > > --- > > > src/qemu/qemu_alias.c | 18 ++ > > > 1 file changed, 14 insertions(+), 4 deletions(-) [...] > > > @@ -634,7 +644,7 @@ qemuAssignDeviceAliases(virDomainDef *def, > > > virQEMUCaps *qemuCaps) > > > } > > > > > > for (i = 0; i < def->nfss; i++) { > > > -if (qemuAssignDeviceFSAlias(def->fss[i], i) < 0) > > > +if (qemuAssignDeviceFSAlias(def, def->fss[i]) < 0) > > > return -1; > > > > Are other devices also n^2 during startup of the VM? > > > > For the alias assingment, many of the hotpluggable ones are. Sigh. Reviewed-by: Peter Krempa
Re: [libvirt PATCH 10/16] qemu: alias: prepare qemuAssignDeviceFSAlias for disjunct ranges
On a Wednesday in 2021, Peter Krempa wrote: On Wed, Oct 06, 2021 at 09:15:16 +0200, Ján Tomko wrote: Iterate through the array to find the first free index. Signed-off-by: Ján Tomko --- src/qemu/qemu_alias.c | 18 ++ 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 81a1e7eeed..4153050bec 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -336,13 +336,23 @@ qemuAssignDeviceNetAlias(virDomainDef *def, static int -qemuAssignDeviceFSAlias(virDomainFSDef *fss, -int idx) +qemuAssignDeviceFSAlias(virDomainDef *def, +virDomainFSDef *fss) { +size_t i; +int maxidx = 0; + if (fss->info.alias) return 0; -fss->info.alias = g_strdup_printf("fs%d", idx); +for (i = 0; i < def->nfss; i++) { +int idx; + +if ((idx = qemuDomainDeviceAliasIndex(&def->fss[i]->info, "fs")) >= maxidx) +maxidx = idx + 1; +} + +fss->info.alias = g_strdup_printf("fs%d", maxidx); return 0; } @@ -634,7 +644,7 @@ qemuAssignDeviceAliases(virDomainDef *def, virQEMUCaps *qemuCaps) } for (i = 0; i < def->nfss; i++) { -if (qemuAssignDeviceFSAlias(def->fss[i], i) < 0) +if (qemuAssignDeviceFSAlias(def, def->fss[i]) < 0) return -1; Are other devices also n^2 during startup of the VM? For the alias assingment, many of the hotpluggable ones are. Don't know about the rest of the startup code. Jano signature.asc Description: PGP signature
Re: [libvirt PATCH 12/16] qemu: export vhost-user-fs-related functions
On Wed, Oct 06, 2021 at 09:15:18 +0200, Ján Tomko wrote: > Prepare for hotplug support. > > Signed-off-by: Ján Tomko > --- > src/qemu/qemu_alias.c | 2 +- > src/qemu/qemu_alias.h | 4 > src/qemu/qemu_command.c | 2 +- > src/qemu/qemu_command.h | 6 ++ > src/qemu/qemu_hotplug.h | 4 > 5 files changed, 16 insertions(+), 2 deletions(-) Reviewed-by: Peter Krempa
Re: [libvirt PATCH 11/16] qemu: vhost-user-fs: build extdevice for zpci
On Wed, Oct 06, 2021 at 09:15:17 +0200, Ján Tomko wrote: > Other devices (includes 9p-based fsdev) call this wrapper > before formatting the device. > > Add it here too. > > Signed-off-by: Ján Tomko > --- > src/qemu/qemu_command.c | 3 +++ > 1 file changed, 3 insertions(+) Reviewed-by: Peter Krempa
Re: [libvirt PATCH 10/16] qemu: alias: prepare qemuAssignDeviceFSAlias for disjunct ranges
On Wed, Oct 06, 2021 at 09:15:16 +0200, Ján Tomko wrote: > Iterate through the array to find the first free index. > > Signed-off-by: Ján Tomko > --- > src/qemu/qemu_alias.c | 18 ++ > 1 file changed, 14 insertions(+), 4 deletions(-) > > diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c > index 81a1e7eeed..4153050bec 100644 > --- a/src/qemu/qemu_alias.c > +++ b/src/qemu/qemu_alias.c > @@ -336,13 +336,23 @@ qemuAssignDeviceNetAlias(virDomainDef *def, > > > static int > -qemuAssignDeviceFSAlias(virDomainFSDef *fss, > -int idx) > +qemuAssignDeviceFSAlias(virDomainDef *def, > +virDomainFSDef *fss) > { > +size_t i; > +int maxidx = 0; > + > if (fss->info.alias) > return 0; > > -fss->info.alias = g_strdup_printf("fs%d", idx); > +for (i = 0; i < def->nfss; i++) { > +int idx; > + > +if ((idx = qemuDomainDeviceAliasIndex(&def->fss[i]->info, "fs")) >= > maxidx) > +maxidx = idx + 1; > +} > + > +fss->info.alias = g_strdup_printf("fs%d", maxidx); > return 0; > } > > @@ -634,7 +644,7 @@ qemuAssignDeviceAliases(virDomainDef *def, virQEMUCaps > *qemuCaps) > } > > for (i = 0; i < def->nfss; i++) { > -if (qemuAssignDeviceFSAlias(def->fss[i], i) < 0) > +if (qemuAssignDeviceFSAlias(def, def->fss[i]) < 0) > return -1; Are other devices also n^2 during startup of the VM?
Re: [libvirt PATCH 09/16] qemu: remove private data from virDomainFSDef
On Wed, Oct 06, 2021 at 09:15:15 +0200, Ján Tomko wrote: > This reverts commit 801e6da29c0202946d44b42136cc4ee229932a29 > > They are not needed anymore. > > Signed-off-by: Ján Tomko > --- > src/qemu/qemu_domain.c | 41 - > src/qemu/qemu_domain.h | 11 --- > 2 files changed, 52 deletions(-) Reviewed-by: Peter Krempa
Re: [libvirt PATCH 07/16] qemu: vhost-user-fs: separate building of device string
On Wed, Oct 06, 2021 at 09:15:13 +0200, Ján Tomko wrote: > Signed-off-by: Ján Tomko > --- > src/qemu/qemu_command.c | 55 ++--- > 1 file changed, 35 insertions(+), 20 deletions(-) Reviewed-by: Peter Krempa
Re: [libvirt PATCH 08/16] qemu: do not put virtiofs socket in private data
On Wed, Oct 06, 2021 at 09:15:14 +0200, Ján Tomko wrote: > Reconstruct the socket path from priv->libDir in every user. > > Signed-off-by: Ján Tomko > --- > src/qemu/qemu_command.c | 8 +--- > src/qemu/qemu_extdevice.c | 6 ++ > src/qemu/qemu_virtiofs.c | 14 +++--- > tests/qemuxml2argvtest.c | 12 > 4 files changed, 14 insertions(+), 26 deletions(-) Reviewed-by: Peter Krempa
Re: [libvirt PATCH 06/16] qemu: vhost-user-fs: separate building of chardev string
On Wed, Oct 06, 2021 at 09:15:12 +0200, Ján Tomko wrote: > Signed-off-by: Ján Tomko > --- > src/qemu/qemu_command.c | 22 +- > 1 file changed, 17 insertions(+), 5 deletions(-) Reviewed-by: Peter Krempa
Re: [libvirt PATCH 05/16] tests: qemuxml2argvtest: fix path to virtiofs socket
On Wed, Oct 06, 2021 at 09:15:11 +0200, Ján Tomko wrote: > The mocked path in the test suite is not in sync with what libvirtd > generates. > > Signed-off-by: Ján Tomko > --- > .../qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args | 2 +- > .../qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args | 2 +- > tests/qemuxml2argvtest.c| 2 +- > 3 files changed, 3 insertions(+), 3 deletions(-) Reviewed-by: Peter Krempa
Re: [libvirt PATCH 15/16] qemu: implement virtiofs hotplug
On Wed, Oct 06, 2021 at 09:36:46 +0200, Peter Krempa wrote: > On Wed, Oct 06, 2021 at 09:15:21 +0200, Ján Tomko wrote: > > https://bugzilla.redhat.com/show_bug.cgi?id=1897708 > > > > Signed-off-by: Ján Tomko > > --- > > src/qemu/qemu_driver.c | 9 +++- > > src/qemu/qemu_hotplug.c | 96 + > > 2 files changed, 104 insertions(+), 1 deletion(-) > > Preliminary note. The tree fails to compile after this commit: > > ../../../libvirt/src/qemu/qemu_hotplug.c:3401:1: error: no previous prototype > for ‘qemuDomainAttachFSDevice’ [-Werror=missing-prototypes] > 3401 | qemuDomainAttachFSDevice(virQEMUDriver *driver, > | ^~~~ > ../../../libvirt/src/qemu/qemu_hotplug.c: In function > ‘qemuDomainAttachFSDevice’: Never mind. I was lacking one patch, everything is okay.
Re: [libvirt PATCH 04/16] qemu: domain: introduce qemuDomainGetVHostUserChrSourceDef
On Wed, Oct 06, 2021 at 09:15:10 +0200, Ján Tomko wrote: > A function that creates a chardev source with the appropriate > socket path set. > > Signed-off-by: Ján Tomko > --- > src/qemu/qemu_domain.c | 13 + > src/qemu/qemu_domain.h | 4 > 2 files changed, 17 insertions(+) This function is called only from 'qemuDomainAttachFSDevice' thus it doesn't really feel it's worth having as a separate helper. Consider inlining it into the patch actually needing it. Reviewed-by: Peter Krempa
Re: [libvirt PATCH 15/16] qemu: implement virtiofs hotplug
On Wed, Oct 06, 2021 at 09:15:21 +0200, Ján Tomko wrote: > https://bugzilla.redhat.com/show_bug.cgi?id=1897708 > > Signed-off-by: Ján Tomko > --- > src/qemu/qemu_driver.c | 9 +++- > src/qemu/qemu_hotplug.c | 96 + > 2 files changed, 104 insertions(+), 1 deletion(-) Preliminary note. The tree fails to compile after this commit: ../../../libvirt/src/qemu/qemu_hotplug.c:3401:1: error: no previous prototype for ‘qemuDomainAttachFSDevice’ [-Werror=missing-prototypes] 3401 | qemuDomainAttachFSDevice(virQEMUDriver *driver, | ^~~~ ../../../libvirt/src/qemu/qemu_hotplug.c: In function ‘qemuDomainAttachFSDevice’: ../../../libvirt/src/qemu/qemu_hotplug.c:3426:9: error: implicit declaration of function ‘qemuAssignDeviceFSAlias’; did you mean ‘qemuAssignDeviceRNGAlias’? [-Werror=implicit-function-declaration] 3426 | if (qemuAssignDeviceFSAlias(vm->def, fs) < 0) | ^~~ | qemuAssignDeviceRNGAlias ../../../libvirt/src/qemu/qemu_hotplug.c:3426:9: error: nested extern declaration of ‘qemuAssignDeviceFSAlias’ [-Werror=nested-externs] ../../../libvirt/src/qemu/qemu_hotplug.c:3432:20: error: implicit declaration of function ‘qemuBuildVHostUserFsDevStr’; did you mean ‘qemuBuildUSBHostdevDevStr’? [-Werror=implicit-function-declaration] 3432 | if (!(devstr = qemuBuildVHostUserFsDevStr(fs, vm->def, charAlias, priv))) |^~ |qemuBuildUSBHostdevDevStr ../../../libvirt/src/qemu/qemu_hotplug.c:3432:20: error: nested extern declaration of ‘qemuBuildVHostUserFsDevStr’ [-Werror=nested-externs] ../../../libvirt/src/qemu/qemu_hotplug.c:3432:18: error: assignment to ‘char *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion] 3432 | if (!(devstr = qemuBuildVHostUserFsDevStr(fs, vm->def, charAlias, priv))) | ^ cc1: all warnings being treated as errors
Re: [libvirt PATCH 03/16] qemu: domain: introduce qemuDomainGetVHostUserFSSocketPath
On Wed, Oct 06, 2021 at 09:15:09 +0200, Ján Tomko wrote: > Intended as a replacement for qemuVirtioFSCreateSocketFilename, > to be used outside of qemu_virtiofs.c > > Signed-off-by: Ján Tomko > --- > src/qemu/qemu_domain.c | 10 ++ > src/qemu/qemu_domain.h | 4 > 2 files changed, 14 insertions(+) > > diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c > index a755f8678e..cb6aaecdee 100644 > --- a/src/qemu/qemu_domain.c > +++ b/src/qemu/qemu_domain.c > @@ -11440,3 +11440,13 @@ qemuDomainNamePathsCleanup(virQEMUDriverConfig *cfg, > > return 0; > } > + > + > +char * > +qemuDomainGetVHostUserFSSocketPath(qemuDomainObjPrivate *priv, > + const virDomainFSDef *fs) > +{ > +if (fs->sock) > +return g_strdup(fs->sock); Empty line here please. > +return virFileBuildPath(priv->libDir, fs->info.alias, "-fs.sock"); > +} Reviewed-by: Peter Krempa
Re: [libvirt PATCH 02/16] conf: define cleanup func for virDomainChrSourceDef
On Wed, Oct 06, 2021 at 09:15:08 +0200, Ján Tomko wrote: It's defined also for 'virDomainChrDef' > Signed-off-by: Ján Tomko > --- > src/conf/domain_conf.h | 2 ++ > 1 file changed, 2 insertions(+) Reviewed-by: Peter Krempa
Re: [libvirt PATCH 01/16] qemu: vhost-user-fs: format alias on the command line
On Wed, Oct 06, 2021 at 09:15:07 +0200, Ján Tomko wrote: > The commit adding the vhost-user-fs device forgot to format > the device's alias on the command line. > > Thankfully it was not needed yet because virtiofs migration > is not yet supported, but it will be needed in the future > to allow hot(un)plug. > > Signed-off-by: Ján Tomko > --- > src/qemu/qemu_command.c | 1 + > .../qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args | 2 +- > .../qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args | 2 +- > 3 files changed, 3 insertions(+), 2 deletions(-) Reviewed-by: Peter Krempa
[libvirt PATCH 16/16] qemu: implement virtiofs hotunplug
Signed-off-by: Ján Tomko --- src/conf/domain_conf.c | 24 src/conf/domain_conf.h | 2 + src/libvirt_private.syms | 1 + src/qemu/qemu_hotplug.c | 81 +++- 4 files changed, 106 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b8370f6950..057dbf91a5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -28829,6 +28829,30 @@ virDomainFSRemove(virDomainDef *def, size_t i) return fs; } +ssize_t +virDomainFSDefFind(virDomainDef *def, + virDomainFSDef *fs) +{ +size_t i = 0; + +for (i = 0; i < def->nfss; i++) { +virDomainFSDef *tmp = def->fss[i]; + +if (fs->dst && STRNEQ_NULLABLE(fs->dst, tmp->dst)) +continue; + +if (fs->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && +!virDomainDeviceInfoAddressIsEqual(&fs->info, &tmp->info)) +continue; + +if (fs->info.alias && STRNEQ_NULLABLE(fs->info.alias, tmp->info.alias)) +continue; + +return i; +} +return -1; +} + virDomainFSDef * virDomainGetFilesystemForTarget(virDomainDef *def, const char *target) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index c23c233184..1fcef7b0e1 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3757,6 +3757,8 @@ virDomainFSDef *virDomainGetFilesystemForTarget(virDomainDef *def, int virDomainFSInsert(virDomainDef *def, virDomainFSDef *fs); int virDomainFSIndexByName(virDomainDef *def, const char *name); virDomainFSDef *virDomainFSRemove(virDomainDef *def, size_t i); +ssize_t virDomainFSDefFind(virDomainDef *def, + virDomainFSDef *fs); unsigned int virDomainVideoDefaultRAM(const virDomainDef *def, const virDomainVideoType type); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fd0eea0777..687a3bbc4c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -410,6 +410,7 @@ virDomainFeatureTypeFromString; virDomainFeatureTypeToString; virDomainFSAccessModeTypeToString; virDomainFSCacheModeTypeToString; +virDomainFSDefFind; virDomainFSDefFree; virDomainFSDefNew; virDomainFSDriverTypeToString; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index f5dad0b829..713da5ebfc 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -5180,6 +5180,45 @@ qemuDomainRemoveRedirdevDevice(virQEMUDriver *driver, } +static int +qemuDomainRemoveFSDevice(virQEMUDriver *driver, + virDomainObj *vm, + virDomainFSDef *fs) +{ +g_autofree char *charAlias = NULL; +qemuDomainObjPrivate *priv = vm->privateData; +ssize_t idx; +int rc = 0; + +VIR_DEBUG("Removing FS device %s from domain %p %s", + fs->info.alias, vm, vm->def->name); + +charAlias = qemuDomainGetVhostUserChrAlias(fs->info.alias); + +qemuDomainObjEnterMonitor(driver, vm); + +if (qemuMonitorDetachCharDev(priv->mon, charAlias) < 0) +rc = -1; + +if (qemuDomainObjExitMonitor(driver, vm) < 0) +return -1; + +virDomainAuditFS(vm, fs, NULL, "detach", rc == 0); + +if (rc < 0) +return -1; + +if (!fs->sock) +qemuVirtioFSStop(driver, vm, fs); + +if ((idx = virDomainFSDefFind(vm->def, fs)) >= 0) +virDomainFSRemove(vm->def, idx); +qemuDomainReleaseDeviceAddress(vm, &fs->info); +virDomainFSDefFree(fs); +return 0; +} + + static void qemuDomainRemoveAuditDevice(virDomainObj *vm, virDomainDeviceDef *detach, @@ -5218,6 +5257,10 @@ qemuDomainRemoveAuditDevice(virDomainObj *vm, virDomainAuditRedirdev(vm, detach->data.redirdev, "detach", success); break; +case VIR_DOMAIN_DEVICE_FS: +virDomainAuditFS(vm, detach->data.fs, NULL, "detach", success); +break; + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_CONTROLLER: case VIR_DOMAIN_DEVICE_WATCHDOG: @@ -5225,7 +5268,6 @@ qemuDomainRemoveAuditDevice(virDomainObj *vm, /* These devices don't have associated audit logs */ break; -case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_GRAPHICS: @@ -5323,9 +5365,13 @@ qemuDomainRemoveDevice(virQEMUDriver *driver, return -1; break; +case VIR_DOMAIN_DEVICE_FS: +if (qemuDomainRemoveFSDevice(driver, vm, dev->data.fs) < 0) +return -1; +break; + case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_LEASE: -case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_GRAPHICS: @@ -6020,6 +6066,31 @@ qemuDomainDetachPrepVsock(virDomainObj *vm, } +static int +qemuDomainDetachPrepFS(virDomainObj *vm, +
[libvirt PATCH 14/16] qemu: use priv->logCtxt in qemuProcessLaunch
Remove the local variable in favor of the one stored in priv. Signed-off-by: Ján Tomko --- src/qemu/qemu_process.c | 20 +--- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 4a1fd753ee..17435c0ee9 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7179,7 +7179,6 @@ qemuProcessLaunch(virConnectPtr conn, int ret = -1; int rv; int logfile = -1; -qemuDomainLogContext *logCtxt = NULL; qemuDomainObjPrivate *priv = vm->privateData; g_autoptr(virCommand) cmd = NULL; struct qemuProcessHookData hookData; @@ -7228,25 +7227,24 @@ qemuProcessLaunch(virConnectPtr conn, hookData.cfg = cfg; VIR_DEBUG("Creating domain log file"); -if (!(logCtxt = qemuDomainLogContextNew(driver, vm, +if (!(priv->logCtxt = qemuDomainLogContextNew(driver, vm, QEMU_DOMAIN_LOG_CONTEXT_MODE_START))) { virLastErrorPrefixMessage("%s", _("can't connect to virtlogd")); goto cleanup; } -priv->logCtxt = logCtxt; -logfile = qemuDomainLogContextGetWriteFD(logCtxt); +logfile = qemuDomainLogContextGetWriteFD(priv->logCtxt); if (qemuProcessGenID(vm, flags) < 0) goto cleanup; if (qemuExtDevicesStart(driver, vm, -qemuDomainLogContextGetManager(logCtxt), +qemuDomainLogContextGetManager(priv->logCtxt), incoming != NULL) < 0) goto cleanup; VIR_DEBUG("Building emulator command line"); if (!(cmd = qemuBuildCommandLine(driver, - qemuDomainLogContextGetManager(logCtxt), + qemuDomainLogContextGetManager(priv->logCtxt), driver->securityManager, vm, incoming ? incoming->launchURI : NULL, @@ -7265,11 +7263,11 @@ qemuProcessLaunch(virConnectPtr conn, VIR_HOOK_SUBOP_BEGIN) < 0) goto cleanup; -qemuLogOperation(vm, "starting up", cmd, logCtxt); +qemuLogOperation(vm, "starting up", cmd, priv->logCtxt); -qemuDomainObjCheckTaint(driver, vm, logCtxt, incoming != NULL); +qemuDomainObjCheckTaint(driver, vm, priv->logCtxt, incoming != NULL); -qemuDomainLogContextMarkPosition(logCtxt); +qemuDomainLogContextMarkPosition(priv->logCtxt); VIR_DEBUG("Building mount namespace"); @@ -7343,7 +7341,7 @@ qemuProcessLaunch(virConnectPtr conn, VIR_DEBUG("Waiting for handshake from child"); if (virCommandHandshakeWait(cmd) < 0) { /* Read errors from child that occurred between fork and exec. */ -qemuProcessReportLogError(logCtxt, +qemuProcessReportLogError(priv->logCtxt, _("Process exited prior to exec")); goto cleanup; } @@ -7423,7 +7421,7 @@ qemuProcessLaunch(virConnectPtr conn, goto cleanup; VIR_DEBUG("Waiting for monitor to show up"); -if (qemuProcessWaitForMonitor(driver, vm, asyncJob, logCtxt) < 0) +if (qemuProcessWaitForMonitor(driver, vm, asyncJob, priv->logCtxt) < 0) goto cleanup; if (qemuConnectAgent(driver, vm) < 0) -- 2.31.1
[libvirt PATCH 12/16] qemu: export vhost-user-fs-related functions
Prepare for hotplug support. Signed-off-by: Ján Tomko --- src/qemu/qemu_alias.c | 2 +- src/qemu/qemu_alias.h | 4 src/qemu/qemu_command.c | 2 +- src/qemu/qemu_command.h | 6 ++ src/qemu/qemu_hotplug.h | 4 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 4153050bec..276a03cb56 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -335,7 +335,7 @@ qemuAssignDeviceNetAlias(virDomainDef *def, } -static int +int qemuAssignDeviceFSAlias(virDomainDef *def, virDomainFSDef *fss) { diff --git a/src/qemu/qemu_alias.h b/src/qemu/qemu_alias.h index cfce05833d..604e667b9a 100644 --- a/src/qemu/qemu_alias.h +++ b/src/qemu/qemu_alias.h @@ -46,6 +46,10 @@ int qemuAssignDeviceNetAlias(virDomainDef *def, virDomainNetDef *net, int idx); +int +qemuAssignDeviceFSAlias(virDomainDef *def, +virDomainFSDef *fss); + int qemuAssignDeviceRedirdevAlias(virDomainDef *def, virDomainRedirdevDef *redirdev, int idx); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8c8aafb13d..28bca1519c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2049,7 +2049,7 @@ qemuBuildVHostUserFsChardevStr(const virDomainFSDef *fs, } -static char * +char * qemuBuildVHostUserFsDevStr(virDomainFSDef *fs, const virDomainDef *def, const char *chardev_alias, diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index a0e6af9d3f..6b8f90f737 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -144,6 +144,12 @@ char virDomainDiskDef *disk, virQEMUCaps *qemuCaps); +char * +qemuBuildVHostUserFsDevStr(virDomainFSDef *fs, + const virDomainDef *def, + const char *chardev_alias, + qemuDomainObjPrivate *priv); + /* Current, best practice */ int qemuBuildControllerDevStr(const virDomainDef *domainDef, virDomainControllerDef *def, diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index 9f383f4602..244dd5278d 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -107,6 +107,10 @@ int qemuDomainAttachInputDevice(virQEMUDriver *driver, int qemuDomainAttachVsockDevice(virQEMUDriver *driver, virDomainObj *vm, virDomainVsockDef *vsock); +int +qemuDomainAttachFSDevice(virQEMUDriver *driver, + virDomainObj *vm, + virDomainFSDef *fs); int qemuDomainAttachLease(virQEMUDriver *driver, virDomainObj *vm, -- 2.31.1
[libvirt PATCH 11/16] qemu: vhost-user-fs: build extdevice for zpci
Other devices (includes 9p-based fsdev) call this wrapper before formatting the device. Add it here too. Signed-off-by: Ján Tomko --- src/qemu/qemu_command.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index dc4f91ce25..8c8aafb13d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2095,6 +2095,9 @@ qemuBuildVHostUserFsCommandLine(virCommand *cmd, virCommandAddArg(cmd, "-chardev"); virCommandAddArg(cmd, chrdevstr); +if (qemuCommandAddExtDevice(cmd, &fs->info) < 0) +return -1; + if (!(devstr = qemuBuildVHostUserFsDevStr(fs, def, chardev_alias, priv))) return -1; -- 2.31.1
[libvirt PATCH 09/16] qemu: remove private data from virDomainFSDef
This reverts commit 801e6da29c0202946d44b42136cc4ee229932a29 They are not needed anymore. Signed-off-by: Ján Tomko --- src/qemu/qemu_domain.c | 41 - src/qemu/qemu_domain.h | 11 --- 2 files changed, 52 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5f467760c3..c4c79d979a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -983,46 +983,6 @@ qemuDomainNetworkPrivateDispose(void *obj G_GNUC_UNUSED) } -static virClass *qemuDomainFSPrivateClass; -static void qemuDomainFSPrivateDispose(void *obj); - - -static int -qemuDomainFSPrivateOnceInit(void) -{ -if (!VIR_CLASS_NEW(qemuDomainFSPrivate, virClassForObject())) -return -1; - -return 0; -} - - -VIR_ONCE_GLOBAL_INIT(qemuDomainFSPrivate); - - -static virObject * -qemuDomainFSPrivateNew(void) -{ -qemuDomainFSPrivate *priv; - -if (qemuDomainFSPrivateInitialize() < 0) -return NULL; - -if (!(priv = virObjectNew(qemuDomainFSPrivateClass))) -return NULL; - -return (virObject *) priv; -} - - -static void -qemuDomainFSPrivateDispose(void *obj) -{ -qemuDomainFSPrivate *priv = obj; - -g_free(priv->vhostuser_fs_sock); -} - static virClass *qemuDomainVideoPrivateClass; static void qemuDomainVideoPrivateDispose(void *obj); @@ -3163,7 +3123,6 @@ virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks = { .graphicsNew = qemuDomainGraphicsPrivateNew, .networkNew = qemuDomainNetworkPrivateNew, .videoNew = qemuDomainVideoPrivateNew, -.fsNew = qemuDomainFSPrivateNew, .parse = qemuDomainObjPrivateXMLParse, .format = qemuDomainObjPrivateXMLFormat, .getParseOpaque = qemuDomainObjPrivateXMLGetParseOpaque, diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 59cb703c16..7e717cf2ad 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -392,17 +392,6 @@ struct _qemuDomainNetworkPrivate { }; -#define QEMU_DOMAIN_FS_PRIVATE(dev) \ -((qemuDomainFSPrivate *) (dev)->privateData) - -typedef struct _qemuDomainFSPrivate qemuDomainFSPrivate; -struct _qemuDomainFSPrivate { -virObject parent; - -char *vhostuser_fs_sock; -}; - - typedef enum { QEMU_PROCESS_EVENT_WATCHDOG = 0, QEMU_PROCESS_EVENT_GUESTPANIC, -- 2.31.1
[libvirt PATCH 08/16] qemu: do not put virtiofs socket in private data
Reconstruct the socket path from priv->libDir in every user. Signed-off-by: Ján Tomko --- src/qemu/qemu_command.c | 8 +--- src/qemu/qemu_extdevice.c | 6 ++ src/qemu/qemu_virtiofs.c | 14 +++--- tests/qemuxml2argvtest.c | 12 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d0f961b8ea..dc4f91ce25 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2035,14 +2035,16 @@ qemuBuildDisksCommandLine(virCommand *cmd, static char * qemuBuildVHostUserFsChardevStr(const virDomainFSDef *fs, - const char *chardev_alias) + const char *chardev_alias, + qemuDomainObjPrivate *priv) { g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; +g_autofree char *socket_path = qemuDomainGetVHostUserFSSocketPath(priv, fs); virBufferAddLit(&buf, "socket"); virBufferAsprintf(&buf, ",id=%s", chardev_alias); virBufferAddLit(&buf, ",path="); -virQEMUBuildBufferEscapeComma(&buf, QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock); +virQEMUBuildBufferEscapeComma(&buf, socket_path); return virBufferContentAndReset(&buf); } @@ -2088,7 +2090,7 @@ qemuBuildVHostUserFsCommandLine(virCommand *cmd, g_autofree char *devstr = NULL; chardev_alias = qemuDomainGetVhostUserChrAlias(fs->info.alias); -chrdevstr = qemuBuildVHostUserFsChardevStr(fs, chardev_alias); +chrdevstr = qemuBuildVHostUserFsChardevStr(fs, chardev_alias, priv); virCommandAddArg(cmd, "-chardev"); virCommandAddArg(cmd, chrdevstr); diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index 98b546fc73..ef0b3f1981 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -196,10 +196,8 @@ qemuExtDevicesStart(virQEMUDriver *driver, for (i = 0; i < def->nfss; i++) { virDomainFSDef *fs = def->fss[i]; -if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) { -if (fs->sock) -QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock = g_strdup(fs->sock); -else if (qemuVirtioFSStart(logManager, driver, vm, fs) < 0) +if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS && !fs->sock) { +if (qemuVirtioFSStart(logManager, driver, vm, fs) < 0) return -1; } } diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c index 15c05479c8..08a8b4ed42 100644 --- a/src/qemu/qemu_virtiofs.c +++ b/src/qemu/qemu_virtiofs.c @@ -183,8 +183,7 @@ qemuVirtioFSStart(virLogManager *logManager, if (!(pidfile = qemuVirtioFSCreatePidFilename(vm, fs->info.alias))) goto cleanup; -if (!(socket_path = qemuVirtioFSCreateSocketFilename(vm, fs->info.alias))) -goto cleanup; +socket_path = qemuDomainGetVHostUserFSSocketPath(vm->privateData, fs); if ((fd = qemuVirtioFSOpenChardev(driver, vm, socket_path)) < 0) goto cleanup; @@ -251,12 +250,9 @@ qemuVirtioFSStart(virLogManager *logManager, goto error; } -QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock = g_steal_pointer(&socket_path); ret = 0; cleanup: -if (socket_path) -unlink(socket_path); return ret; error: @@ -264,6 +260,8 @@ qemuVirtioFSStart(virLogManager *logManager, virProcessKillPainfully(pid, true); if (pidfile) unlink(pidfile); +if (socket_path) +unlink(socket_path); goto cleanup; } @@ -284,8 +282,10 @@ qemuVirtioFSStop(virQEMUDriver *driver G_GNUC_UNUSED, if (virPidFileForceCleanupPathFull(pidfile, true) < 0) { VIR_WARN("Unable to kill virtiofsd process"); } else { -if (QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock) -unlink(QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock); +g_autofree char *socket_path = NULL; + +socket_path = qemuDomainGetVHostUserFSSocketPath(vm->privateData, fs); +unlink(socket_path); } cleanup: diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index e35380293c..7df3946751 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -436,18 +436,6 @@ testCompareXMLToArgvCreateArgs(virQEMUDriver *drv, } } -for (i = 0; i < vm->def->nfss; i++) { -virDomainFSDef *fs = vm->def->fss[i]; -char *s; - -if (fs->fsdriver != VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS || -QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock) -continue; - -s = g_strdup_printf("/tmp/lib/domain--1-guest/fs%zu-fs.sock", i); -QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock = s; -} - if (vm->def->vsock) { virDomainVsockDef *vsock = vm->def->vsock; qemuDomainVsockPrivate *vsockPriv = -- 2.31.1
[libvirt PATCH 07/16] qemu: vhost-user-fs: separate building of device string
Signed-off-by: Ján Tomko --- src/qemu/qemu_command.c | 55 ++--- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7e76e188c1..d0f961b8ea 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2047,6 +2047,36 @@ qemuBuildVHostUserFsChardevStr(const virDomainFSDef *fs, } +static char * +qemuBuildVHostUserFsDevStr(virDomainFSDef *fs, + const virDomainDef *def, + const char *chardev_alias, + qemuDomainObjPrivate *priv) +{ +g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + +if (qemuBuildVirtioDevStr(&buf, "vhost-user-fs", priv->qemuCaps, + VIR_DOMAIN_DEVICE_FS, fs) < 0) +return NULL; + +virBufferAsprintf(&buf, ",id=%s", fs->info.alias); +virBufferAsprintf(&buf, ",chardev=%s", chardev_alias); +if (fs->queue_size) +virBufferAsprintf(&buf, ",queue-size=%llu", fs->queue_size); +virBufferAddLit(&buf, ",tag="); +virQEMUBuildBufferEscapeComma(&buf, fs->dst); +qemuBuildVirtioOptionsStr(&buf, fs->virtio); + +if (fs->info.bootIndex) +virBufferAsprintf(&buf, ",bootindex=%u", fs->info.bootIndex); + +if (qemuBuildDeviceAddressStr(&buf, def, &fs->info) < 0) +return NULL; + +return virBufferContentAndReset(&buf); +} + + static int qemuBuildVHostUserFsCommandLine(virCommand *cmd, virDomainFSDef *fs, @@ -2055,7 +2085,7 @@ qemuBuildVHostUserFsCommandLine(virCommand *cmd, { g_autofree char *chardev_alias = NULL; g_autofree char *chrdevstr = NULL; -g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER; +g_autofree char *devstr = NULL; chardev_alias = qemuDomainGetVhostUserChrAlias(fs->info.alias); chrdevstr = qemuBuildVHostUserFsChardevStr(fs, chardev_alias); @@ -2063,27 +2093,12 @@ qemuBuildVHostUserFsCommandLine(virCommand *cmd, virCommandAddArg(cmd, "-chardev"); virCommandAddArg(cmd, chrdevstr); +if (!(devstr = qemuBuildVHostUserFsDevStr(fs, def, chardev_alias, priv))) +return -1; + virCommandAddArg(cmd, "-device"); +virCommandAddArg(cmd, devstr); -if (qemuBuildVirtioDevStr(&opt, "vhost-user-fs", priv->qemuCaps, - VIR_DOMAIN_DEVICE_FS, fs) < 0) -return -1; - -virBufferAsprintf(&opt, ",id=%s", fs->info.alias); -virBufferAsprintf(&opt, ",chardev=%s", chardev_alias); -if (fs->queue_size) -virBufferAsprintf(&opt, ",queue-size=%llu", fs->queue_size); -virBufferAddLit(&opt, ",tag="); -virQEMUBuildBufferEscapeComma(&opt, fs->dst); -qemuBuildVirtioOptionsStr(&opt, fs->virtio); - -if (fs->info.bootIndex) -virBufferAsprintf(&opt, ",bootindex=%u", fs->info.bootIndex); - -if (qemuBuildDeviceAddressStr(&opt, def, &fs->info) < 0) -return -1; - -virCommandAddArgBuffer(cmd, &opt); return 0; } -- 2.31.1
[libvirt PATCH 15/16] qemu: implement virtiofs hotplug
https://bugzilla.redhat.com/show_bug.cgi?id=1897708 Signed-off-by: Ján Tomko --- src/qemu/qemu_driver.c | 9 +++- src/qemu/qemu_hotplug.c | 96 + 2 files changed, 104 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 760d30a867..65b2ef8e86 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6945,8 +6945,15 @@ qemuDomainAttachDeviceLive(virDomainObj *vm, } break; -case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_FS: +ret = qemuDomainAttachFSDevice(driver, vm, dev->data.fs); +if (ret == 0) { +alias = dev->data.fs->info.alias; +dev->data.fs = NULL; +} +break; + +case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_GRAPHICS: diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 22239b2689..f5dad0b829 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -35,6 +35,7 @@ #include "qemu_security.h" #include "qemu_block.h" #include "qemu_snapshot.h" +#include "qemu_virtiofs.h" #include "domain_audit.h" #include "netdev_bandwidth_conf.h" #include "domain_nwfilter.h" @@ -3396,6 +3397,101 @@ qemuDomainAttachVsockDevice(virQEMUDriver *driver, } +int +qemuDomainAttachFSDevice(virQEMUDriver *driver, + virDomainObj *vm, + virDomainFSDef *fs) +{ +qemuDomainObjPrivate *priv = vm->privateData; +virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_FS, + { .fs = fs } }; +g_autoptr(virDomainChrSourceDef) chardev = NULL; +virErrorPtr origErr = NULL; +bool releaseaddr = false; +bool chardevAdded = false; +bool started = false; +g_autofree char *devstr = NULL; +g_autofree char *charAlias = NULL; +int ret = -1; + +if (fs->fsdriver != VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) { +virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("only virtiofs filesystems can be hotplugged")); +return -1; +} + +if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev) < 0) +return -1; + +if (qemuAssignDeviceFSAlias(vm->def, fs) < 0) +goto cleanup; + +chardev = qemuDomainGetVHostUserChrSourceDef(priv, fs); +charAlias = qemuDomainGetVhostUserChrAlias(fs->info.alias); + +if (!(devstr = qemuBuildVHostUserFsDevStr(fs, vm->def, charAlias, priv))) +goto cleanup; + +if (!fs->sock) { +if (qemuVirtioFSPrepareDomain(driver, fs) < 0) +goto cleanup; + +if (qemuVirtioFSStart(qemuDomainLogContextGetManager(priv->logCtxt), driver, vm, fs) < 0) +goto cleanup; +started = true; + +if (qemuVirtioFSSetupCgroup(vm, fs, priv->cgroup) < 0) +goto cleanup; +} + +qemuDomainObjEnterMonitor(driver, vm); + +if (qemuMonitorAttachCharDev(priv->mon, charAlias, chardev) < 0) +goto exit_monitor; +chardevAdded = true; + +if (qemuDomainAttachExtensionDevice(priv->mon, &fs->info) < 0) +goto exit_monitor; + +if (qemuMonitorAddDevice(priv->mon, devstr) < 0) { +ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &fs->info)); +goto exit_monitor; +} + +if (qemuDomainObjExitMonitor(driver, vm) < 0) { +releaseaddr = false; +goto cleanup; +} + +VIR_APPEND_ELEMENT(vm->def->fss, vm->def->nfss, fs); + +ret = 0; + + audit: +virDomainAuditFS(vm, NULL, fs, "attach", ret == 0); + cleanup: +if (ret < 0) { +virErrorPreserveLast(&origErr); +if (releaseaddr) +qemuDomainReleaseDeviceAddress(vm, &fs->info); +if (started) +qemuVirtioFSStop(driver, vm, fs); +virErrorRestore(&origErr); +} + +return ret; + + exit_monitor: +virErrorPreserveLast(&origErr); +if (chardevAdded) +ignore_value(qemuMonitorDetachCharDev(priv->mon, charAlias)); +if (qemuDomainObjExitMonitor(driver, vm) < 0) +releaseaddr = false; +virErrorRestore(&origErr); +goto audit; +} + + int qemuDomainAttachLease(virQEMUDriver *driver, virDomainObj *vm, -- 2.31.1
[libvirt PATCH 06/16] qemu: vhost-user-fs: separate building of chardev string
Signed-off-by: Ján Tomko --- src/qemu/qemu_command.c | 22 +- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 90c8022b07..7e76e188c1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2033,6 +2033,20 @@ qemuBuildDisksCommandLine(virCommand *cmd, } +static char * +qemuBuildVHostUserFsChardevStr(const virDomainFSDef *fs, + const char *chardev_alias) +{ +g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + +virBufferAddLit(&buf, "socket"); +virBufferAsprintf(&buf, ",id=%s", chardev_alias); +virBufferAddLit(&buf, ",path="); +virQEMUBuildBufferEscapeComma(&buf, QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock); +return virBufferContentAndReset(&buf); +} + + static int qemuBuildVHostUserFsCommandLine(virCommand *cmd, virDomainFSDef *fs, @@ -2040,16 +2054,14 @@ qemuBuildVHostUserFsCommandLine(virCommand *cmd, qemuDomainObjPrivate *priv) { g_autofree char *chardev_alias = NULL; +g_autofree char *chrdevstr = NULL; g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER; chardev_alias = qemuDomainGetVhostUserChrAlias(fs->info.alias); +chrdevstr = qemuBuildVHostUserFsChardevStr(fs, chardev_alias); virCommandAddArg(cmd, "-chardev"); -virBufferAddLit(&opt, "socket"); -virBufferAsprintf(&opt, ",id=%s", chardev_alias); -virBufferAddLit(&opt, ",path="); -virQEMUBuildBufferEscapeComma(&opt, QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock); -virCommandAddArgBuffer(cmd, &opt); +virCommandAddArg(cmd, chrdevstr); virCommandAddArg(cmd, "-device"); -- 2.31.1
[libvirt PATCH 05/16] tests: qemuxml2argvtest: fix path to virtiofs socket
The mocked path in the test suite is not in sync with what libvirtd generates. Signed-off-by: Ján Tomko --- .../qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args | 2 +- .../qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args | 2 +- tests/qemuxml2argvtest.c| 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args b/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args index 7586a8edbf..8adab6da81 100644 --- a/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args +++ b/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args @@ -27,7 +27,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -no-shutdown \ -no-acpi \ -boot strict=on \ --chardev socket,id=chr-vu-fs0,path=/tmp/lib/domain--1-guest/fs0.vhost-fs.sock \ +-chardev socket,id=chr-vu-fs0,path=/tmp/lib/domain--1-guest/fs0-fs.sock \ -device vhost-user-fs-pci,id=fs0,chardev=chr-vu-fs0,queue-size=1024,tag=mount_tag,bus=pci.0,addr=0x2 \ -audiodev id=audio1,driver=none \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args b/tests/qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args index 290d0b9e2f..4158456744 100644 --- a/tests/qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args +++ b/tests/qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args @@ -33,7 +33,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/guest.qcow2","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage"}' \ -device virtio-blk-pci,bus=pci.4,addr=0x0,drive=libvirt-1-format,id=virtio-disk0,bootindex=1 \ --chardev socket,id=chr-vu-fs0,path=/tmp/lib/domain--1-guest/fs0.vhost-fs.sock \ +-chardev socket,id=chr-vu-fs0,path=/tmp/lib/domain--1-guest/fs0-fs.sock \ -device vhost-user-fs-pci,id=fs0,chardev=chr-vu-fs0,tag=mount_tag,bootindex=2,bus=pci.1,addr=0x0 \ -audiodev id=audio1,driver=none \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 94aaa2f53e..e35380293c 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -444,7 +444,7 @@ testCompareXMLToArgvCreateArgs(virQEMUDriver *drv, QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock) continue; -s = g_strdup_printf("/tmp/lib/domain--1-guest/fs%zu.vhost-fs.sock", i); +s = g_strdup_printf("/tmp/lib/domain--1-guest/fs%zu-fs.sock", i); QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock = s; } -- 2.31.1
[libvirt PATCH 13/16] qemu: store logCtxt in domain private data
We might need it later for device hotplug. Signed-off-by: Ján Tomko --- src/qemu/qemu_domain.h | 11 +++ src/qemu/qemu_process.c | 5 - 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 7e717cf2ad..fef6a2f39f 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -101,6 +101,9 @@ struct _qemuDomainSecretInfo { char *ciphertext; /* encoded/encrypted secret */ }; +#define QEMU_TYPE_DOMAIN_LOG_CONTEXT qemu_domain_log_context_get_type() +G_DECLARE_FINAL_TYPE(qemuDomainLogContext, qemu_domain_log_context, QEMU, DOMAIN_LOG_CONTEXT, GObject); + typedef struct _qemuDomainObjPrivate qemuDomainObjPrivate; struct _qemuDomainObjPrivate { virQEMUDriver *driver; @@ -193,6 +196,10 @@ struct _qemuDomainObjPrivate { * provided by QEMU. */ virCPUDef *origCPU; +/* Log context. After startup, it is also used for hotplugging devices + * with a log file */ +qemuDomainLogContext *logCtxt; + /* If true virtlogd is used as stdio handler for character devices. */ bool chardevStdioLogd; @@ -418,10 +425,6 @@ struct qemuProcessEvent { }; void qemuProcessEventFree(struct qemuProcessEvent *event); - -#define QEMU_TYPE_DOMAIN_LOG_CONTEXT qemu_domain_log_context_get_type() -G_DECLARE_FINAL_TYPE(qemuDomainLogContext, qemu_domain_log_context, QEMU, DOMAIN_LOG_CONTEXT, GObject); - typedef struct _qemuDomainSaveCookie qemuDomainSaveCookie; struct _qemuDomainSaveCookie { virObject parent; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 1d0165af6d..4a1fd753ee 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7179,7 +7179,7 @@ qemuProcessLaunch(virConnectPtr conn, int ret = -1; int rv; int logfile = -1; -g_autoptr(qemuDomainLogContext) logCtxt = NULL; +qemuDomainLogContext *logCtxt = NULL; qemuDomainObjPrivate *priv = vm->privateData; g_autoptr(virCommand) cmd = NULL; struct qemuProcessHookData hookData; @@ -7233,6 +7233,7 @@ qemuProcessLaunch(virConnectPtr conn, virLastErrorPrefixMessage("%s", _("can't connect to virtlogd")); goto cleanup; } +priv->logCtxt = logCtxt; logfile = qemuDomainLogContextGetWriteFD(logCtxt); if (qemuProcessGenID(vm, flags) < 0) @@ -7966,6 +7967,8 @@ void qemuProcessStop(virQEMUDriver *driver, qemuDBusStop(driver, vm); +g_clear_object(&priv->logCtxt); + vm->def->id = -1; /* Wake up anything waiting on domain condition */ -- 2.31.1
[libvirt PATCH 10/16] qemu: alias: prepare qemuAssignDeviceFSAlias for disjunct ranges
Iterate through the array to find the first free index. Signed-off-by: Ján Tomko --- src/qemu/qemu_alias.c | 18 ++ 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 81a1e7eeed..4153050bec 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -336,13 +336,23 @@ qemuAssignDeviceNetAlias(virDomainDef *def, static int -qemuAssignDeviceFSAlias(virDomainFSDef *fss, -int idx) +qemuAssignDeviceFSAlias(virDomainDef *def, +virDomainFSDef *fss) { +size_t i; +int maxidx = 0; + if (fss->info.alias) return 0; -fss->info.alias = g_strdup_printf("fs%d", idx); +for (i = 0; i < def->nfss; i++) { +int idx; + +if ((idx = qemuDomainDeviceAliasIndex(&def->fss[i]->info, "fs")) >= maxidx) +maxidx = idx + 1; +} + +fss->info.alias = g_strdup_printf("fs%d", maxidx); return 0; } @@ -634,7 +644,7 @@ qemuAssignDeviceAliases(virDomainDef *def, virQEMUCaps *qemuCaps) } for (i = 0; i < def->nfss; i++) { -if (qemuAssignDeviceFSAlias(def->fss[i], i) < 0) +if (qemuAssignDeviceFSAlias(def, def->fss[i]) < 0) return -1; } for (i = 0; i < def->nsounds; i++) { -- 2.31.1
[libvirt PATCH 03/16] qemu: domain: introduce qemuDomainGetVHostUserFSSocketPath
Intended as a replacement for qemuVirtioFSCreateSocketFilename, to be used outside of qemu_virtiofs.c Signed-off-by: Ján Tomko --- src/qemu/qemu_domain.c | 10 ++ src/qemu/qemu_domain.h | 4 2 files changed, 14 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a755f8678e..cb6aaecdee 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11440,3 +11440,13 @@ qemuDomainNamePathsCleanup(virQEMUDriverConfig *cfg, return 0; } + + +char * +qemuDomainGetVHostUserFSSocketPath(qemuDomainObjPrivate *priv, + const virDomainFSDef *fs) +{ +if (fs->sock) +return g_strdup(fs->sock); +return virFileBuildPath(priv->libDir, fs->info.alias, "-fs.sock"); +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 64f92988b7..aad076dd4c 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1043,3 +1043,7 @@ int qemuDomainNamePathsCleanup(virQEMUDriverConfig *cfg, const char *name, bool bestEffort); + +char * +qemuDomainGetVHostUserFSSocketPath(qemuDomainObjPrivate *priv, + const virDomainFSDef *fs); -- 2.31.1
[libvirt PATCH 04/16] qemu: domain: introduce qemuDomainGetVHostUserChrSourceDef
A function that creates a chardev source with the appropriate socket path set. Signed-off-by: Ján Tomko --- src/qemu/qemu_domain.c | 13 + src/qemu/qemu_domain.h | 4 2 files changed, 17 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index cb6aaecdee..5f467760c3 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11450,3 +11450,16 @@ qemuDomainGetVHostUserFSSocketPath(qemuDomainObjPrivate *priv, return g_strdup(fs->sock); return virFileBuildPath(priv->libDir, fs->info.alias, "-fs.sock"); } + + +virDomainChrSourceDef * +qemuDomainGetVHostUserChrSourceDef(qemuDomainObjPrivate *priv, + const virDomainFSDef *fs) +{ +virDomainChrSourceDef *src = virDomainChrSourceDefNew(priv->driver->xmlopt); + +src->type = VIR_DOMAIN_CHR_TYPE_UNIX; +src->data.nix.path = qemuDomainGetVHostUserFSSocketPath(priv, fs); + +return src; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index aad076dd4c..59cb703c16 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1047,3 +1047,7 @@ qemuDomainNamePathsCleanup(virQEMUDriverConfig *cfg, char * qemuDomainGetVHostUserFSSocketPath(qemuDomainObjPrivate *priv, const virDomainFSDef *fs); + +virDomainChrSourceDef * +qemuDomainGetVHostUserChrSourceDef(qemuDomainObjPrivate *priv, + const virDomainFSDef *fs); -- 2.31.1
[libvirt PATCH 00/16] qemu: implement virtiofs hot(un)plug (virtiofs epopee)
https://bugzilla.redhat.com/show_bug.cgi?id=1897708 Ján Tomko (16): qemu: vhost-user-fs: format alias on the command line conf: define cleanup func for virDomainChrSourceDef qemu: domain: introduce qemuDomainGetVHostUserFSSocketPath qemu: domain: introduce qemuDomainGetVHostUserChrSourceDef tests: qemuxml2argvtest: fix path to virtiofs socket qemu: vhost-user-fs: separate building of chardev string qemu: vhost-user-fs: separate building of device string qemu: do not put virtiofs socket in private data qemu: remove private data from virDomainFSDef qemu: alias: prepare qemuAssignDeviceFSAlias for disjunct ranges qemu: vhost-user-fs: build extdevice for zpci qemu: export vhost-user-fs-related functions qemu: store logCtxt in domain private data qemu: use priv->logCtxt in qemuProcessLaunch qemu: implement virtiofs hotplug qemu: implement virtiofs hotunplug src/conf/domain_conf.c| 24 +++ src/conf/domain_conf.h| 4 + src/libvirt_private.syms | 1 + src/qemu/qemu_alias.c | 20 +- src/qemu/qemu_alias.h | 4 + src/qemu/qemu_command.c | 81 +--- src/qemu/qemu_command.h | 6 + src/qemu/qemu_domain.c| 64 +++ src/qemu/qemu_domain.h| 30 +-- src/qemu/qemu_driver.c| 9 +- src/qemu/qemu_extdevice.c | 6 +- src/qemu/qemu_hotplug.c | 177 +- src/qemu/qemu_hotplug.h | 4 + src/qemu/qemu_process.c | 21 ++- src/qemu/qemu_virtiofs.c | 14 +- ...vhost-user-fs-fd-memory.x86_64-latest.args | 4 +- ...vhost-user-fs-hugepages.x86_64-latest.args | 4 +- tests/qemuxml2argvtest.c | 12 -- 18 files changed, 360 insertions(+), 125 deletions(-) -- 2.31.1
[libvirt PATCH 01/16] qemu: vhost-user-fs: format alias on the command line
The commit adding the vhost-user-fs device forgot to format the device's alias on the command line. Thankfully it was not needed yet because virtiofs migration is not yet supported, but it will be needed in the future to allow hot(un)plug. Signed-off-by: Ján Tomko --- src/qemu/qemu_command.c | 1 + .../qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args | 2 +- .../qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 08f6d735f8..90c8022b07 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2057,6 +2057,7 @@ qemuBuildVHostUserFsCommandLine(virCommand *cmd, VIR_DOMAIN_DEVICE_FS, fs) < 0) return -1; +virBufferAsprintf(&opt, ",id=%s", fs->info.alias); virBufferAsprintf(&opt, ",chardev=%s", chardev_alias); if (fs->queue_size) virBufferAsprintf(&opt, ",queue-size=%llu", fs->queue_size); diff --git a/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args b/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args index 6311f8f65e..7586a8edbf 100644 --- a/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args +++ b/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args @@ -28,7 +28,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -no-acpi \ -boot strict=on \ -chardev socket,id=chr-vu-fs0,path=/tmp/lib/domain--1-guest/fs0.vhost-fs.sock \ --device vhost-user-fs-pci,chardev=chr-vu-fs0,queue-size=1024,tag=mount_tag,bus=pci.0,addr=0x2 \ +-device vhost-user-fs-pci,id=fs0,chardev=chr-vu-fs0,queue-size=1024,tag=mount_tag,bus=pci.0,addr=0x2 \ -audiodev id=audio1,driver=none \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args b/tests/qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args index 58570592eb..290d0b9e2f 100644 --- a/tests/qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args +++ b/tests/qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args @@ -34,7 +34,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage"}' \ -device virtio-blk-pci,bus=pci.4,addr=0x0,drive=libvirt-1-format,id=virtio-disk0,bootindex=1 \ -chardev socket,id=chr-vu-fs0,path=/tmp/lib/domain--1-guest/fs0.vhost-fs.sock \ --device vhost-user-fs-pci,chardev=chr-vu-fs0,tag=mount_tag,bootindex=2,bus=pci.1,addr=0x0 \ +-device vhost-user-fs-pci,id=fs0,chardev=chr-vu-fs0,tag=mount_tag,bootindex=2,bus=pci.1,addr=0x0 \ -audiodev id=audio1,driver=none \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on -- 2.31.1
[libvirt PATCH 02/16] conf: define cleanup func for virDomainChrSourceDef
Signed-off-by: Ján Tomko --- src/conf/domain_conf.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e054c1508e..c23c233184 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1284,6 +1284,7 @@ struct _virDomainChrSourceDef { size_t nseclabels; virSecurityDeviceLabelDef **seclabels; }; +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainChrSourceDef, virObjectUnref); /* A complete character device, both host and domain views. */ struct _virDomainChrDef { @@ -3300,6 +3301,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainNetDef, virDomainNetDefFree); void virDomainSmartcardDefFree(virDomainSmartcardDef *def); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainSmartcardDef, virDomainSmartcardDefFree); void virDomainChrDefFree(virDomainChrDef *def); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainChrDef, virDomainChrDefFree); int virDomainChrSourceDefCopy(virDomainChrSourceDef *dest, virDomainChrSourceDef *src); void virDomainSoundCodecDefFree(virDomainSoundCodecDef *def); -- 2.31.1