[PATCH] vm : forbid to start a removing vm
by Hogan Wang
From: Zhuang Shengen <zhuangshengen(a)huawei.com>
When a vm is doing migration phase confirm, and then start it concurrently,
it will lead to the vm out of libvirtd control.
Cause Analysis:
1. thread1 migrate vm out.
2. thread2 start the migrating vm.
3. thread1 remove vm from domain list after migrate success.
4. thread2 acquired the vm job success and start the vm.
5. cannot find the vm any more by 'virsh list' command. Actually,
the started vm is not exist in the domain list.
Solution:
Check the vm->removing state before start.
Signed-off-by: Zhuang Shengen <zhuangshengen(a)huawei.com>
Reviewed-by: Hogan Wang <hogan.wang(a)huawei.com>
---
src/qemu/qemu_driver.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d1a3659774..a5dfea94cb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6637,6 +6637,12 @@ qemuDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
goto endjob;
}
+ if (vm->removing) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is already removing"));
+ goto endjob;
+ }
+
if (qemuDomainObjStart(dom->conn, driver, vm, flags,
QEMU_ASYNC_JOB_START) < 0)
goto endjob;
--
2.23.0
3 years, 6 months
[PATCH] rpc: libssh2: Enable EC host keys
by Bastian Germann
libssh2 has ECDSA and ED25519 support beginning with v1.9.0. libvirt cannot
make use of those because it will handle them as unknown key types.
Add support for those host key types.
Signed-off-by: Bastian Germann <bastiangermann(a)fishpost.de>
---
src/rpc/virnetsshsession.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c
index fe77594..c311e90 100644
--- a/src/rpc/virnetsshsession.c
+++ b/src/rpc/virnetsshsession.c
@@ -389,7 +389,21 @@ virNetSSHCheckHostKey(virNetSSHSessionPtr sess)
case LIBSSH2_HOSTKEY_TYPE_DSS:
keyType = LIBSSH2_KNOWNHOST_KEY_SSHDSS;
break;
-
+#ifdef LIBSSH2_HOSTKEY_TYPE_ED25519
+ /* defs from libssh2 v1.9.0 or later */
+ case LIBSSH2_HOSTKEY_TYPE_ECDSA_256:
+ keyType = LIBSSH2_KNOWNHOST_KEY_ECDSA_256;
+ break;
+ case LIBSSH2_HOSTKEY_TYPE_ECDSA_384:
+ keyType = LIBSSH2_KNOWNHOST_KEY_ECDSA_384;
+ break;
+ case LIBSSH2_HOSTKEY_TYPE_ECDSA_521:
+ keyType = LIBSSH2_KNOWNHOST_KEY_ECDSA_521;
+ break;
+ case LIBSSH2_HOSTKEY_TYPE_ED25519:
+ keyType = LIBSSH2_KNOWNHOST_KEY_ED25519;
+ break;
+#endif
case LIBSSH2_HOSTKEY_TYPE_UNKNOWN:
default:
virReportError(VIR_ERR_SSH, "%s",
--
2.31.0
3 years, 7 months
[PATCH 0/3] tests: qemuxml2argv negative tests for hugepages and numatune
by Han Han
Han Han (3):
tests: negative test for hugepages with anonymous memory backing
tests: negative test for hugepages with ondemand mode
tests: negative test of binding memnode cellid to an nonexist guest
cell
.../qemuxml2argvdata/hugepages-anonymous.err | 1 +
.../qemuxml2argvdata/hugepages-anonymous.xml | 25 +++++++++++++++
tests/qemuxml2argvdata/hugepages-ondemand.err | 1 +
tests/qemuxml2argvdata/hugepages-ondemand.xml | 25 +++++++++++++++
...une-memnode-cellid-nonexist-guest-cell.err | 1 +
...une-memnode-cellid-nonexist-guest-cell.xml | 31 +++++++++++++++++++
tests/qemuxml2argvtest.c | 3 ++
7 files changed, 87 insertions(+)
create mode 100644 tests/qemuxml2argvdata/hugepages-anonymous.err
create mode 100644 tests/qemuxml2argvdata/hugepages-anonymous.xml
create mode 100644 tests/qemuxml2argvdata/hugepages-ondemand.err
create mode 100644 tests/qemuxml2argvdata/hugepages-ondemand.xml
create mode 100644 tests/qemuxml2argvdata/numatune-memnode-cellid-nonexist-guest-cell.err
create mode 100644 tests/qemuxml2argvdata/numatune-memnode-cellid-nonexist-guest-cell.xml
--
2.30.2
3 years, 7 months
[libvirt PATCHv1 0/4] qemu: support unmanaged virtiofsd
by Ján Tomko
Connect the vhost-user-fs device to a socket path configured in the XML.
Starting and stopping the virtiofsd daemon on that socket is the user's
responsibility.
Ján Tomko (4):
conf: fs: fill out accessmode in post-parse
conf: fs: allow missing accessmode in the formatter
conf: add socket for virtiofs filesystems
qemu: add socket for virtiofs filesystems
docs/schemas/domaincommon.rng | 11 +++++
src/conf/domain_conf.c | 43 +++++++++++++------
src/conf/domain_conf.h | 2 +
src/qemu/qemu_extdevice.c | 10 +++--
src/qemu/qemu_validate.c | 17 +++++---
tests/qemuxml2argvdata/vhost-user-fs-sock.xml | 39 +++++++++++++++++
.../vhost-user-fs-sock.x86_64-latest.xml | 1 +
tests/qemuxml2xmltest.c | 1 +
8 files changed, 102 insertions(+), 22 deletions(-)
create mode 100644 tests/qemuxml2argvdata/vhost-user-fs-sock.xml
create mode 120000 tests/qemuxml2xmloutdata/vhost-user-fs-sock.x86_64-latest.xml
--
2.29.2
3 years, 7 months
[PATCH v2 0/2] qemu: virtiofs: support <sandbox mode='chroot'/>
by Cole Robinson
Add support for virtiofsd -o sandbox=chroot|namespace
v2:
Add link to virtiofsd docs in libvirt docs
validate the new field for qemu
break up the patch
Cole Robinson (2):
conf: Introduce <sandbox mode='chroot'/> for <filesystem><binary>
qemu: virtiofs: support <sandbox mode='chroot'/>
docs/formatdomain.rst | 6 +++++
docs/schemas/domaincommon.rng | 12 ++++++++++
src/conf/domain_conf.c | 23 +++++++++++++++++++
src/conf/domain_conf.h | 10 ++++++++
src/libvirt_private.syms | 1 +
src/qemu/qemu_validate.c | 7 ++++++
src/qemu/qemu_virtiofs.c | 2 ++
.../vhost-user-fs-fd-memory.xml | 1 +
8 files changed, 62 insertions(+)
--
2.30.2
3 years, 7 months
[PATCH 00/10] To make <transient/> disk sharable for qemu
by Masayoshi Mizuma
This patch series has two parts; the first part is trying to support
for hotplugging disks with <transient/> option for qemu, and make the
disk shareable when <shareable/> disk option is set as well.
The second part is trying to make shareable the disks with <transient/>
disk option which is described on the domain xml. The second part
is marked as Work In Progress (WIP) because the design may be modified
by the first part changes.
Reference:
- RFC PATCH: https://listman.redhat.com/archives/libvir-list/2021-January/msg01035.html
Masayoshi Mizuma (10):
qemu_hotplug: Add transient disk hotplug support
qemu_hotplug: make transient disk sharable
virsh: Add transient flag for disk hotplug
tests/qemuhotplugtest: Add qemu caps flags to the argument of DO_TEST
tests/qemumonitortestutils: Add JobStatusChange to update progress of
blockdev-create
tests/qemuhotplugtest: Add transient disk hotplug test
WIP: qemu_snapshot: Add the guest name to the transient disk path
WIP: qemu_hotplug: Add asynJob to disk hotplug utilities
WIP: qemu_hotplug: make transient disk sharable
WIP: tests/qemuxml2argvdata: Add shareable transient disk test
src/qemu/qemu_command.c | 11 +
src/qemu/qemu_hotplug.c | 262 ++++++++++++++++--
src/qemu/qemu_hotplug.h | 3 +
src/qemu/qemu_process.c | 23 +-
src/qemu/qemu_process.h | 7 +
src/qemu/qemu_snapshot.c | 12 +-
src/qemu/qemu_validate.c | 21 +-
tests/qemuhotplugtest.c | 199 ++++++++-----
.../qemuhotplug-disk-scsi-transient.xml | 7 +
.../qemuhotplug-disk-virtio-transient.xml | 7 +
...lug-transient-live+disk-scsi-transient.xml | 65 +++++
...g-transient-live+disk-virtio-transient.xml | 65 +++++
.../qemuhotplug-transient-live.xml | 51 ++++
tests/qemumonitortestutils.c | 22 +-
...isk-transient-shareable.x86_64-latest.args | 41 +++
.../disk-transient-shareable.xml | 26 ++
tests/qemuxml2argvtest.c | 1 +
tools/virsh-domain.c | 8 +
18 files changed, 738 insertions(+), 93 deletions(-)
create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-disk-scsi-transient.xml
create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-disk-virtio-transient.xml
create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-transient-live+disk-scsi-transient.xml
create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-transient-live+disk-virtio-transient.xml
create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-transient-live.xml
create mode 100644 tests/qemuxml2argvdata/disk-transient-shareable.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/disk-transient-shareable.xml
--
2.27.0
3 years, 7 months
[libvirt PATCH v6 00/30] Add support for persistent mediated devices
by Jonathon Jongsma
This patch series follows the previously-merged series which added support for
transient mediated devices. This series expands mdev support to include
persistent device definitions. Again, it relies on mdevctl as the backend.
It follows the common libvirt pattern of APIs by adding the following new APIs
for node devices:
- virNodeDeviceDefineXML() - defines a persistent device
- virNodeDeviceUndefine() - undefines a persistent device
- virNodeDeviceCreate() - starts a previously-defined device
It also adds virsh commands mapping to these new APIs: nodedev-define,
nodedev-undefine, and nodedev-start.
Since we rely on mdevctl for the definition of mediated devices, we need a way
to stay up-to-date with devices that are defined by mdevctl (outside of
libvirt). The method for staying up-to-date is currently a little bit crude
due to the fact that mdevctl does not emit any events when new devices are
added or removed. As a workaround, we create a file monitor for the mdevctl
config directory and re-query mdevctl when we detect changes within that
directory. In the future, mdevctl may introduce a more elegant solution.
Changes in v6:
- rebase to git master again
- remove typedefs for various *Ptr types, since they're now discouraged in
libvirt.
Changes in v5:
- Rebase to git master
- updated new API version info to 7.2.0
- capture and relay stderr message from mdevctl
- changed to using GHashTable functions directly instead of deprecated
virHash functions
- protected mdevctlMonitors with a mutex
- added a couple patches to fix the 5s delay when defining a new mdev. These
are currently separate patches added to the end of the series, but could be
squashed into the earlier commits if that's preferred.
- various other minor review fixes
Changes in v4:
- rebase to git master
- switch to throwaway thread for querying mdevctl
- fixed a bug when removing devices because I was accidentally using
virHashForEach() instead of virHashForeachSafe()
- use DEFINED/UNDEFINED events instead of STARTED/STOPPED events
- changes related to merging information about mdev devices from both udev a=
nd
mdevctl:
- Re-used the same function to copy extra data from mdevctl regardless of
whether we're processing a udev event or a mdevctl event (recommended by
Erik). This results in slightly more complex handling of the object
lifetimes (see patch 9), but it consolidates some code.
- nodeDeviceDefCopyFromMdevctl() previously only copied the data that was
unique to mdevctl and didn't exist in udev. It now copies additional data
(possibly overwriting some udev). This solves a problem where a device =
is
defined but not active (i.e. we have not gotten any data from udev), and
then changed (e.g. somebody calls 'mdevctl modify' to change the mdev
type), but libvirt was not updating to the new definition.
- fix a bug where we were mistakenly emitting 'update' events for devices th=
at
had not changed
- Added the ability to specify a uuid for an mdev via device XML.
- split some commits into multiple patches
- updated new API version info to 7.1.0
- Fixed a bug reported by Yan Fu which hangs the client when attempting to
destroy a nodedev that is in use by an active vm. See
https://www.redhat.com/archives/libvir-list/2021-February/msg00116.html for
solution suggested by Alex.
- numerous smaller fixes from review findings
changes in v3:
- streamlined tests -- removed some unnecessary duplication
- split out patch to factor out node device name generation function
- split nodeDeviceParseMdevctlChildDevice() into a separate function
- added follow-up patch to remove space-padded alignment in header
- refactored the mdevctl update handling significantly:
- no longer a separate persistent thread that gets signaled by a timer
- now piggybacks onto the existing udev thread and signals the thread in t=
he
same way that the udev event does.
- Daniel suggested spawning a throw-away thread to handle mdevctl updates,
but that introduces the complexity of possibly serializing multiple
throw-away threads (e.g. if we get an 'created' event followed immediate=
ly
by a 'deleted' event, two threads may be spawned and we'd need to ensure
they are properly ordered)
- added virNodeDeviceObjListForEach() and virNodeDeviceObjListRemoveLocked()
to simplify removing devices that are removed from mdevctl.
- coding style fixes
- NOTE: per Erik's request, I experimented with changing the way that mdevctl
commands were generated and tested (e.g. introducing something like
virMdevctlGetCommand(def, MDEVCTL_COMMAND_<SUBCOMMAND>, ...)), but it was
too invasive and awkward and didn't seem worthwhile
Changes in v2:
- rebase to latest git master
Jonathon Jongsma (30):
nodedev: capture and report stderror from mdevctl
tests: remove extra trailing semicolon
nodedev: introduce concept of 'active' node devices
nodedev: Add ability to filter by active state
nodedev: fix docs for virConnectListAllNodeDevices()
nodedev: expose internal helper for naming devices
nodedev: add ability to parse mdevs from mdevctl
nodedev: add ability to list defined mdevs
nodedev: add persistence to virNodeDeviceObj
nodedev: add DEFINED/UNDEFINED lifecycle events
nodedev: add mdevctl devices to node device list
nodedev: add helper functions to remove node devices
nodedev: handle mdevs that disappear from mdevctl
nodedev: Refresh mdev devices when changes are detected
nodedev: add function to generate mdevctl define command
api: add virNodeDeviceDefineXML()
virsh: Add --inactive, --all to nodedev-list
virsh: add nodedev-define command
nodedev: refactor tests to support mdev undefine
api: add virNodeDeviceUndefine()
virsh: Factor out function to find node device
virsh: add nodedev-undefine command
api: add virNodeDeviceCreate()
virsh: add "nodedev-start" command
nodedev: add <uuid> element to mdev caps
nodedev: add ability to specify UUID for new mdevs
nodedev: fix hang when destroying an mdev in use
nodedev: add docs about mdev attribute order
nodedev: factor out function to add mediated devices
nodedev: avoid delay when defining a new mdev
docs/formatnode.html.in | 5 +-
docs/schemas/nodedev.rng | 43 +-
examples/c/misc/event-test.c | 4 +
include/libvirt/libvirt-nodedev.h | 20 +-
src/access/viraccessperm.c | 2 +-
src/access/viraccessperm.h | 6 +
src/conf/node_device_conf.c | 14 +
src/conf/node_device_conf.h | 8 +
src/conf/virnodedeviceobj.c | 147 +++-
src/conf/virnodedeviceobj.h | 24 +
src/driver-nodedev.h | 14 +
src/libvirt-nodedev.c | 141 +++-
src/libvirt_private.syms | 6 +
src/libvirt_public.syms | 3 +
src/node_device/node_device_driver.c | 743 +++++++++++++++++-
src/node_device/node_device_driver.h | 50 +-
src/node_device/node_device_udev.c | 217 ++++-
src/remote/remote_driver.c | 3 +
src/remote/remote_protocol.x | 40 +-
src/remote_protocol-structs | 16 +
src/rpc/gendispatch.pl | 1 +
...19_36ea_4111_8f0a_8c9a70e21366-define.argv | 2 +
...19_36ea_4111_8f0a_8c9a70e21366-define.json | 1 +
...019_36ea_4111_8f0a_8c9a70e21366-start.argv | 3 +-
...39_495e_4243_ad9f_beb3f14c23d9-define.argv | 1 +
...39_495e_4243_ad9f_beb3f14c23d9-define.json | 1 +
...16_1ca8_49ac_b176_871d16c13076-define.argv | 1 +
...16_1ca8_49ac_b176_871d16c13076-define.json | 1 +
tests/nodedevmdevctldata/mdevctl-create.argv | 1 +
.../mdevctl-list-defined.argv | 1 +
.../mdevctl-list-multiple.json | 59 ++
.../mdevctl-list-multiple.out.xml | 43 +
.../nodedevmdevctldata/mdevctl-undefine.argv | 1 +
tests/nodedevmdevctltest.c | 232 +++++-
...v_d069d019_36ea_4111_8f0a_8c9a70e21366.xml | 1 +
tools/virsh-nodedev.c | 269 ++++++-
36 files changed, 1931 insertions(+), 193 deletions(-)
create mode 100644 tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9=
a70e21366-define.argv
create mode 100644 tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9=
a70e21366-define.json
create mode 100644 tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb=
3f14c23d9-define.argv
create mode 100644 tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb=
3f14c23d9-define.json
create mode 100644 tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871=
d16c13076-define.argv
create mode 100644 tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871=
d16c13076-define.json
create mode 100644 tests/nodedevmdevctldata/mdevctl-create.argv
create mode 100644 tests/nodedevmdevctldata/mdevctl-list-defined.argv
create mode 100644 tests/nodedevmdevctldata/mdevctl-list-multiple.json
create mode 100644 tests/nodedevmdevctldata/mdevctl-list-multiple.out.xml
create mode 100644 tests/nodedevmdevctldata/mdevctl-undefine.argv
--=20
2.26.3
3 years, 7 months
[PATCH] virfile: Replace AbsPath judgement method with g_path_is_absolute()
by Luke Yue
The g_path_is_absolute() considers more situations
than just a simply "path[0] == '/'".
Related issue: https://gitlab.com/libvirt/libvirt/-/issues/12
Signed-off-by: Luke Yue <lukedyue(a)gmail.com>
---
src/util/virfile.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 93fac200cc..3311eaff3d 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -3153,7 +3153,7 @@ virFileOpenTty(int *ttyprimary G_GNUC_UNUSED,
int
virFileAbsPath(const char *path, char **abspath)
{
- if (path[0] == '/') {
+ if (g_path_is_absolute(path)) {
*abspath = g_strdup(path);
} else {
g_autofree char *buf = g_get_current_dir();
--
2.31.1
3 years, 7 months
[libvirt][PATCH v4 0/3] introduce 'restrictive' mode in numatune
by Luyao Zhong
Before this patch set, numatune only has three memory modes:
static, interleave and prefered. These memory policies are
ultimately set by mbind() system call.
Memory policy could be 'hard coded' into the kernel, but none of
above policies fit our requirment under this case. mbind() support
default memory policy, but it requires a NULL nodemask. So obviously
setting allowed memory nodes is cgroups' mission under this case.
So we introduce a new option for mode in numatune named 'restrictive'.
<numatune>
<memory mode="restrictive" nodeset="1-4,^3"/>
<memnode cellid="0" mode="restrictive" nodeset="1"/>
<memnode cellid="2" mode="restrictive" nodeset="2"/>
</numatune>
The config above means we only use cgroups to restrict the allowed
memory nodes and not setting any specific memory policies explicitly.
RFC discussion:
https://www.redhat.com/archives/libvir-list/2020-November/msg01256.html
Regards,
Luyao
Luyao Zhong (3):
docs: add docs for 'restrictive' option for mode in numatune
schema: add 'restrictive' config option for mode in numatune
qemu: add parser and formatter for 'restrictive' mode in numatune
docs/formatdomain.rst | 7 +++-
docs/schemas/domaincommon.rng | 2 +
include/libvirt/libvirt-domain.h | 1 +
src/conf/numa_conf.c | 9 ++++
src/qemu/qemu_command.c | 6 ++-
src/qemu/qemu_process.c | 27 ++++++++++++
src/util/virnuma.c | 3 ++
.../numatune-memnode-invalid-mode.err | 1 +
.../numatune-memnode-invalid-mode.xml | 33 +++++++++++++++
...emnode-restrictive-mode.x86_64-latest.args | 40 ++++++++++++++++++
.../numatune-memnode-restrictive-mode.xml | 33 +++++++++++++++
tests/qemuxml2argvtest.c | 2 +
...memnode-restrictive-mode.x86_64-latest.xml | 41 +++++++++++++++++++
tests/qemuxml2xmltest.c | 1 +
14 files changed, 203 insertions(+), 3 deletions(-)
create mode 100644 tests/qemuxml2argvdata/numatune-memnode-invalid-mode.err
create mode 100644 tests/qemuxml2argvdata/numatune-memnode-invalid-mode.xml
create mode 100644 tests/qemuxml2argvdata/numatune-memnode-restrictive-mode.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/numatune-memnode-restrictive-mode.xml
create mode 100644 tests/qemuxml2xmloutdata/numatune-memnode-restrictive-mode.x86_64-latest.xml
--
2.25.4
3 years, 7 months
[PATCH 0/1] vircgroup: Fix nested cgroup on cleanup
by Eric Farman
Hi Pavel, et al,
Running Fedora 33 KVM/QEMU on s390x, I recently noticed a couple
of oddities when shutting down my guests, which I bisected between
7.0.0 and 7.1.0 to your commit:
commit 184245f53b94fc84f727eb6e8a2aa52df02d69c0
Author: Pavel Hrdina <phrdina(a)redhat.com>
Date: Tue Feb 9 12:33:53 2021 +0100
vircgroup: introduce nested cgroup to properly work with systemd
The attached patch is based on some of the tweaks you did to use the
parent/nested pointers in a cgroup, rather than a cgroup itself.
It fixes both problems I'm encountering, but as this code is quite
unfamiliar to me, I might well be way off track and would appreciate
your feedback in the matter.
Apologies for hitting this on the same day as freeze; I had not
noticed the messages previously, and started digging yesterday when
I noted the number of file descriptors left open by libvirt.
Thanks,
Eric
Eric Farman (1):
vircgroup: Cleanup nested cgroups
src/util/vircgroup.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--
2.25.1
3 years, 7 months