[libvirt] [PATCH v2 0/8] Speed up waiting for the session daemon
by Martin Kletzander
This is complete rework of:
http://www.redhat.com/archives/libvir-list/2013-April/msg01351.html
where Daniel suggested we use systemd-like passing of socket fd in
combination with the LISTEN_FDS environment variable:
http://www.redhat.com/archives/libvir-list/2013-April/msg01356.html
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=927369
Martin Kletzander (8):
util: abstract parsing of passed FDs into virGetListenFDs()
remote: create virNetServerServiceNewFDOrUNIX() wrapper
rpc: set listen backlog on FDs as well as on other sockets
daemon: support passing FDs from the calling process
cfg.mk: allow integers to be assigned a value computed with i|j|k
tests: support dynamic prefixes in commandtest
util: add virCommandPassListenFDs() function
rpc: pass listen FD to the daemon being started
cfg.mk | 2 +-
daemon/libvirtd.c | 45 ++++++++++--------
src/libvirt_private.syms | 2 +
src/libvirt_remote.syms | 1 +
src/locking/lock_daemon.c | 47 ++-----------------
src/rpc/virnetserverservice.c | 53 ++++++++++++++++++++-
src/rpc/virnetserverservice.h | 15 +++++-
src/rpc/virnetsocket.c | 58 +++++++++++++++--------
src/util/vircommand.c | 99 +++++++++++++++++++++++++++++++++++++++
src/util/vircommand.h | 4 +-
src/util/virutil.c | 51 ++++++++++++++++++++
src/util/virutil.h | 2 +
tests/commanddata/test24.log | 7 +++
tests/commandtest.c | 105 ++++++++++++++++++++++++++++++++++--------
14 files changed, 389 insertions(+), 102 deletions(-)
create mode 100644 tests/commanddata/test24.log
--
2.0.0
10 years, 4 months
[libvirt] [PATCH] nodedev: fix pci express memory leak
by Eric Blake
Leak introduced in commit 16ebf10f (v1.2.6), detected by valgrind:
==9816== 216 (96 direct, 120 indirect) bytes in 6 blocks are definitely lost in loss record 665 of 821
==9816== at 0x4A081D4: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==9816== by 0x50836FB: virAlloc (viralloc.c:144)
==9816== by 0x1DBDBE27: udevProcessPCI (node_device_udev.c:546)
==9816== by 0x1DBDD79D: udevGetDeviceDetails (node_device_udev.c:1293)
While at it, fix switch statements to be a bit more vocal if we forget
some cases when adding new devices.
* src/conf/node_device_conf.c (virNodeDeviceDefFormat)
(virNodeDevCapsDefParseXML): Drop default case.
(virNodeDevCapsDefFree): Likewise, and clear pci_express under pci
case.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
I could be persuaded to split this into two patches.
src/conf/node_device_conf.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 910a371..4b34fec 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -547,7 +547,6 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDef *def)
case VIR_NODE_DEV_CAP_FC_HOST:
case VIR_NODE_DEV_CAP_VPORTS:
case VIR_NODE_DEV_CAP_LAST:
- default:
break;
}
@@ -1405,7 +1404,10 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt,
case VIR_NODE_DEV_CAP_STORAGE:
ret = virNodeDevCapStorageParseXML(ctxt, def, node, &caps->data);
break;
- default:
+ case VIR_NODE_DEV_CAP_FC_HOST:
+ case VIR_NODE_DEV_CAP_VPORTS:
+ case VIR_NODE_DEV_CAP_SCSI_GENERIC:
+ case VIR_NODE_DEV_CAP_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown capability type '%d' for '%s'"),
caps->type, def->name);
@@ -1665,6 +1667,7 @@ void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
VIR_FREE(data->pci_dev.iommuGroupDevices[i]);
}
VIR_FREE(data->pci_dev.iommuGroupDevices);
+ VIR_FREE(data->pci_dev.pci_express);
break;
case VIR_NODE_DEV_CAP_USB_DEV:
VIR_FREE(data->usb_dev.product_name);
@@ -1703,7 +1706,6 @@ void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
case VIR_NODE_DEV_CAP_FC_HOST:
case VIR_NODE_DEV_CAP_VPORTS:
case VIR_NODE_DEV_CAP_LAST:
- default:
/* This case is here to shutup the compiler */
break;
}
--
1.9.3
10 years, 4 months
[libvirt] [PATCH] metadata: track title edits across libvirtd restart
by Eric Blake
https://bugzilla.redhat.com/show_bug.cgi?id=1122205
Although the edits were changing in-memory XML, it was not flushed
to disk; so unless some other action changes XML, a libvirtd restart
would lose the changed information.
* src/conf/domain_conf.c (virDomainObjSetMetadata): Add parameter,
to save live status across restarts.
(virDomainSaveXML): Allow for test driver.
* src/conf/domain_conf.h (virDomainObjSetMetadata): Adjust
signature.
* src/bhyve/bhyve_driver.c (bhyveDomainSetMetadata): Adjust caller.
* src/lxc/lxc_driver.c (lxcDomainSetMetadata): Likewise.
* src/qemu/qemu_driver.c (qemuDomainSetMetadata): Likewise.
* src/test/test_driver.c (testDomainSetMetadata): Likewise.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/bhyve/bhyve_driver.c | 3 ++-
src/conf/domain_conf.c | 9 ++++++++-
src/conf/domain_conf.h | 1 +
src/lxc/lxc_driver.c | 3 ++-
src/qemu/qemu_driver.c | 3 ++-
src/test/test_driver.c | 2 +-
6 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 9a13076..135cb24 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -1046,7 +1046,8 @@ bhyveDomainSetMetadata(virDomainPtr dom,
goto cleanup;
ret = virDomainObjSetMetadata(vm, type, metadata, key, uri, caps,
- privconn->xmlopt, BHYVE_CONFIG_DIR, flags);
+ privconn->xmlopt, BHYVE_STATE_DIR,
+ BHYVE_CONFIG_DIR, flags);
cleanup:
virObjectUnref(caps);
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4b00280..6ed6155 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18111,6 +18111,9 @@ virDomainSaveXML(const char *configDir,
char *configFile = NULL;
int ret = -1;
+ if (!configDir)
+ return 0;
+
if ((configFile = virDomainConfigFile(configDir, def->name)) == NULL)
goto cleanup;
@@ -19741,6 +19744,7 @@ virDomainObjSetMetadata(virDomainObjPtr vm,
const char *uri,
virCapsPtr caps,
virDomainXMLOptionPtr xmlopt,
+ const char *stateDir,
const char *configDir,
unsigned int flags)
{
@@ -19753,9 +19757,12 @@ virDomainObjSetMetadata(virDomainObjPtr vm,
&persistentDef) < 0)
return -1;
- if (flags & VIR_DOMAIN_AFFECT_LIVE)
+ if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (virDomainDefSetMetadata(vm->def, type, metadata, key, uri) < 0)
return -1;
+ if (virDomainSaveStatus(xmlopt, stateDir, vm) < 0)
+ return -1;
+ }
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
if (virDomainDefSetMetadata(persistentDef, type, metadata, key, uri) < 0)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index f5eb031..d89bbe7 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2715,6 +2715,7 @@ int virDomainObjSetMetadata(virDomainObjPtr vm,
const char *uri,
virCapsPtr caps,
virDomainXMLOptionPtr xmlopt,
+ const char *stateDir,
const char *configDir,
unsigned int flags);
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index b7b4b02..855222f 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -5600,7 +5600,8 @@ lxcDomainSetMetadata(virDomainPtr dom,
goto cleanup;
ret = virDomainObjSetMetadata(vm, type, metadata, key, uri, caps,
- driver->xmlopt, cfg->configDir, flags);
+ driver->xmlopt, cfg->stateDir,
+ cfg->configDir, flags);
cleanup:
virObjectUnlock(vm);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9d23f6d..72e4a91 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16128,7 +16128,8 @@ qemuDomainSetMetadata(virDomainPtr dom,
goto cleanup;
ret = virDomainObjSetMetadata(vm, type, metadata, key, uri, caps,
- driver->xmlopt, cfg->configDir, flags);
+ driver->xmlopt, cfg->stateDir,
+ cfg->configDir, flags);
cleanup:
virObjectUnlock(vm);
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 67f637d..3b22cf6 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -3042,7 +3042,7 @@ static int testDomainSetMetadata(virDomainPtr dom,
ret = virDomainObjSetMetadata(privdom, type, metadata, key, uri,
privconn->caps, privconn->xmlopt,
- NULL, flags);
+ NULL, NULL, flags);
cleanup:
if (privdom)
--
1.9.3
10 years, 4 months
[libvirt] [PATCHv2 0/2] Tri-state bool enum cleanups
by Ján Tomko
v2: better names
move to virutil and use them in network_conf and device_conf too
Ján Tomko (2):
Introduce virTristateBool enum type
Introduce virTristateSwitch enum
src/conf/device_conf.c | 8 +-
src/conf/device_conf.h | 10 ---
src/conf/domain_conf.c | 202 +++++++++++++++-----------------------------
src/conf/domain_conf.h | 116 ++-----------------------
src/conf/network_conf.c | 11 +--
src/conf/network_conf.h | 15 +---
src/libvirt_private.syms | 28 +-----
src/libxl/libxl_conf.c | 6 +-
src/lxc/lxc_container.c | 4 +-
src/lxc/lxc_native.c | 2 +-
src/network/bridge_driver.c | 3 +-
src/qemu/qemu_command.c | 90 ++++++++++----------
src/qemu/qemu_driver.c | 4 +-
src/qemu/qemu_process.c | 2 +-
src/util/virutil.c | 11 +++
src/util/virutil.h | 21 +++++
src/vbox/vbox_tmpl.c | 22 ++---
src/xenxs/xen_sxpr.c | 20 ++---
src/xenxs/xen_xm.c | 20 ++---
19 files changed, 200 insertions(+), 395 deletions(-)
--
1.8.5.5
10 years, 4 months
[libvirt] [PATCH 0/2] Refactor virMutexInit virRWLockInit and virCondInit
by Jincheng Miao
Implement virMutexInitInternal, virRWLockInitInternal and virCondInitInternal
which include error message reporting.
int virMutexInitInternal(virMutexPtr mutex, bool recursive, bool quite,
const char *filename, const char *funcname,
size_t linenr)
virMutexInit calls virMutexInitInternal with quite == false;
virMutexInitQuite calls virMutexInitInternal with quite == true.
Same for virRWLockInit and virCondInit.
And remove redundant error messages after virMutexInit from other source files.
Jincheng Miao (2):
Refactor virMutexInit virRWLockInit and virCondInit
remove error message when virMutexInit and virCondInit failed
daemon/remote.c | 1 -
src/conf/interface_conf.c | 2 -
src/conf/network_conf.c | 2 -
src/conf/node_device_conf.c | 2 -
src/conf/nwfilter_conf.c | 2 -
src/conf/object_event.c | 2 -
src/conf/storage_conf.c | 2 -
src/conf/virchrdev.c | 2 -
src/esx/esx_vi.c | 15 ++----
src/fdstream.c | 2 -
src/libvirt_private.syms | 7 ++-
src/libxl/libxl_driver.c | 2 -
src/locking/lock_daemon.c | 5 --
src/node_device/node_device_udev.c | 1 -
src/nwfilter/nwfilter_learnipaddr.c | 2 -
src/parallels/parallels_driver.c | 5 +-
src/qemu/qemu_agent.c | 2 -
src/qemu/qemu_capabilities.c | 2 -
src/qemu/qemu_driver.c | 1 -
src/qemu/qemu_monitor.c | 6 +--
src/remote/remote_driver.c | 2 -
src/rpc/virnetclient.c | 5 +-
src/test/test_driver.c | 4 --
src/util/vireventpoll.c | 5 +-
src/util/virlockspace.c | 4 --
src/util/virobject.c | 2 -
src/util/virthread.c | 95 ++++++++++++++++++-------------------
src/util/virthread.h | 57 +++++++++++++++++-----
src/xen/xen_driver.c | 2 -
tests/commandtest.c | 4 +-
tests/qemumonitortestutils.c | 2 -
31 files changed, 103 insertions(+), 144 deletions(-)
--
1.8.3.1
10 years, 4 months
[libvirt] [PATCH] Fix build after 47e5b5ae3262f140955abd57bbb13337c65a3497
by Peter Krempa
The patch described above introduced two problems caught by the compiler
and thus breaking the build.
One of the problems was comparison of unsigned with < 0 and the second
one jumped a variable init.
---
src/lxc/lxc_cgroup.c | 2 +-
src/lxc/lxc_container.c | 74 ++++++++++++++++++++++++-------------------------
2 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
index 572caca..1e96d72 100644
--- a/src/lxc/lxc_cgroup.c
+++ b/src/lxc/lxc_cgroup.c
@@ -337,6 +337,7 @@ virLXCTeardownHostUSBDeviceCgroup(virUSBDevicePtr dev ATTRIBUTE_UNUSED,
static int virLXCCgroupSetupDeviceACL(virDomainDefPtr def,
virCgroupPtr cgroup)
{
+ int capMknod = def->caps_features[VIR_DOMAIN_CAPS_FEATURE_MKNOD];
int ret = -1;
size_t i;
static virLXCCgroupDevicePolicy devices[] = {
@@ -354,7 +355,6 @@ static int virLXCCgroupSetupDeviceACL(virDomainDefPtr def,
goto cleanup;
/* white list mknod if CAP_MKNOD has to be kept */
- int capMknod = def->caps_features[VIR_DOMAIN_CAPS_FEATURE_MKNOD];
if (capMknod == VIR_DOMAIN_FEATURE_STATE_ON) {
if (virCgroupAllowAllDevices(cgroup,
VIR_CGROUP_DEVICE_MKNOD) < 0)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 49028be..81ef961 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1899,43 +1899,43 @@ static int lxcContainerDropCapabilities(virDomainDefPtr def,
int policy = def->features[VIR_DOMAIN_FEATURE_CAPABILITIES];
/* Maps virDomainCapsFeature to CAPS_* */
- static unsigned int capsMapping[] = {CAP_AUDIT_CONTROL,
- CAP_AUDIT_WRITE,
- CAP_BLOCK_SUSPEND,
- CAP_CHOWN,
- CAP_DAC_OVERRIDE,
- CAP_DAC_READ_SEARCH,
- CAP_FOWNER,
- CAP_FSETID,
- CAP_IPC_LOCK,
- CAP_IPC_OWNER,
- CAP_KILL,
- CAP_LEASE,
- CAP_LINUX_IMMUTABLE,
- CAP_MAC_ADMIN,
- CAP_MAC_OVERRIDE,
- CAP_MKNOD,
- CAP_NET_ADMIN,
- CAP_NET_BIND_SERVICE,
- CAP_NET_BROADCAST,
- CAP_NET_RAW,
- CAP_SETGID,
- CAP_SETFCAP,
- CAP_SETPCAP,
- CAP_SETUID,
- CAP_SYS_ADMIN,
- CAP_SYS_BOOT,
- CAP_SYS_CHROOT,
- CAP_SYS_MODULE,
- CAP_SYS_NICE,
- CAP_SYS_PACCT,
- CAP_SYS_PTRACE,
- CAP_SYS_RAWIO,
- CAP_SYS_RESOURCE,
- CAP_SYS_TIME,
- CAP_SYS_TTY_CONFIG,
- CAP_SYSLOG,
- CAP_WAKE_ALARM};
+ static int capsMapping[] = {CAP_AUDIT_CONTROL,
+ CAP_AUDIT_WRITE,
+ CAP_BLOCK_SUSPEND,
+ CAP_CHOWN,
+ CAP_DAC_OVERRIDE,
+ CAP_DAC_READ_SEARCH,
+ CAP_FOWNER,
+ CAP_FSETID,
+ CAP_IPC_LOCK,
+ CAP_IPC_OWNER,
+ CAP_KILL,
+ CAP_LEASE,
+ CAP_LINUX_IMMUTABLE,
+ CAP_MAC_ADMIN,
+ CAP_MAC_OVERRIDE,
+ CAP_MKNOD,
+ CAP_NET_ADMIN,
+ CAP_NET_BIND_SERVICE,
+ CAP_NET_BROADCAST,
+ CAP_NET_RAW,
+ CAP_SETGID,
+ CAP_SETFCAP,
+ CAP_SETPCAP,
+ CAP_SETUID,
+ CAP_SYS_ADMIN,
+ CAP_SYS_BOOT,
+ CAP_SYS_CHROOT,
+ CAP_SYS_MODULE,
+ CAP_SYS_NICE,
+ CAP_SYS_PACCT,
+ CAP_SYS_PTRACE,
+ CAP_SYS_RAWIO,
+ CAP_SYS_RESOURCE,
+ CAP_SYS_TIME,
+ CAP_SYS_TTY_CONFIG,
+ CAP_SYSLOG,
+ CAP_WAKE_ALARM};
capng_get_caps_process();
--
2.0.0
10 years, 4 months
[libvirt] [PATCH] LXC: show used memory as 0 when domain is not active
by Chen Hanxiao
Before:
virsh # dominfo chx3
State: shut off
Max memory: 92160 KiB
Used memory: 92160 KiB
After:
virsh # dominfo container1
State: shut off
Max memory: 92160 KiB
Used memory: 0 KiB
Similar to qemu cases.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
src/lxc/lxc_driver.c | 2 +-
src/qemu/qemu_driver.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index b7b4b02..f094f86 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -584,7 +584,7 @@ static int lxcDomainGetInfo(virDomainPtr dom,
if (!virDomainObjIsActive(vm)) {
info->cpuTime = 0;
- info->memory = vm->def->mem.cur_balloon;
+ info->memory = 0;
} else {
if (virCgroupGetCpuacctUsage(priv->cgroup, &(info->cpuTime)) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 33541d3..01107cf 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2534,7 +2534,7 @@ static int qemuDomainGetInfo(virDomainPtr dom,
info->memory = vm->def->mem.cur_balloon;
}
} else {
- info->memory = vm->def->mem.cur_balloon;
+ info->memory = 0;
}
info->nrVirtCpu = vm->def->vcpus;
--
1.9.0
10 years, 4 months
[libvirt] [libvirt-python PATCH] Bump version to 1.2.7 for new dev cycle
by Martin Kletzander
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
Notes:
pretty late, but pushed as trivial
setup.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index 4e889da..334d7b2 100755
--- a/setup.py
+++ b/setup.py
@@ -309,7 +309,7 @@ class my_clean(clean):
_c_modules, _py_modules = get_module_lists()
setup(name = 'libvirt-python',
- version = '1.2.6',
+ version = '1.2.7',
url = 'http://www.libvirt.org',
maintainer = 'Libvirt Maintainers',
maintainer_email = 'libvir-list(a)redhat.com',
--
2.0.2
10 years, 4 months
[libvirt] [PATCH v1 0/7] Hugepages wrt to NUMA
by Michal Privoznik
Up to now, domains are either backed by an arbitrary huge page but without any
NUMA awareness. This is suboptimal and I'm trying to fix it.
Michal Privoznik (7):
configure: Check for statfs
Introduce virFileFindHugeTLBFS
qemu: Utilize virFileFindHugeTLBFS
virbitmap: Introduce virBitmapDoesIntersect
domain: Introduce ./hugepages/page/[@size,@unit,@nodeset]
qemu: Implement ./hugepages/page/[@size,@unit,@nodeset]
tests: Some testing of hugepages mapping
configure.ac | 4 +-
docs/formatdomain.html.in | 18 +-
docs/schemas/domaincommon.rng | 19 +-
src/Makefile.am | 1 +
src/conf/domain_conf.c | 197 +++++++++++++++++++--
src/conf/domain_conf.h | 13 +-
src/libvirt_private.syms | 2 +
src/parallels/parallels_driver.c | 2 +-
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 111 ++++++++++--
src/qemu/qemu_conf.c | 124 +++++++++++--
src/qemu/qemu_conf.h | 9 +-
src/qemu/qemu_driver.c | 39 ++--
src/qemu/qemu_process.c | 21 ++-
src/util/virbitmap.c | 20 +++
src/util/virbitmap.h | 3 +
src/util/virfile.c | 176 +++++++++++++++++-
src/util/virfile.h | 12 ++
.../qemuxml2argv-hugepages-pages.args | 16 ++
.../qemuxml2argv-hugepages-pages.xml | 45 +++++
.../qemuxml2argv-hugepages-pages2.args | 10 ++
.../qemuxml2argv-hugepages-pages2.xml | 38 ++++
.../qemuxml2argv-hugepages-pages3.args | 9 +
.../qemuxml2argv-hugepages-pages3.xml | 38 ++++
tests/qemuxml2argvdata/qemuxml2argv-hugepages.args | 2 +-
tests/qemuxml2argvtest.c | 18 +-
tests/qemuxml2xmltest.c | 3 +
tests/virbitmaptest.c | 26 +++
29 files changed, 884 insertions(+), 95 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages2.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages2.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages3.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages3.xml
--
1.8.5.5
10 years, 4 months
[libvirt] [PATCH 1/2] blockcommit: track job type in xml
by Eric Blake
A future patch is going to wire up qemu active block commit jobs;
but as they have similar events and are canceled/pivoted in the
same way as block copy jobs, it is easiest to track all bookkeeping
for the commit job by reusing the <mirror> element. This patch
adds domain XML to track which job was responsible for creating a
mirroring situation, and adds a job='copy' attribute to all
existing uses of <mirror>. Along the way, it also massages the
qemu monitor backend to read the new field in order to generate
the correct type of libvirt job (even though it requires a
future patch to actually cause a qemu event that can be reported
as an active commit).
* docs/schemas/domaincommon.rng: Enhance schema.
* docs/formatdomain.html.in: Document it.
* src/conf/domain_conf.h (_virDomainDiskDef): Add a field.
* src/conf/domain_conf.c (virDomainBlockJobType): String conversion.
(virDomainDiskDefParseXML): Parse job type.
(virDomainDiskDefFormat): Output job type.
* src/qemu/qemu_process.c (qemuProcessHandleBlockJob): Distinguish
active from regular commit.
* src/qemu/qemu_driver.c (qemuDomainBlockCopy): Set job type.
(qemuDomainBlockPivot, qemuDomainBlockJobImpl): Clean up job type
on completion.
* tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml:
Update tests.
* tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml: Likewise.
* tests/qemuxml2argvdata/qemuxml2argv-disk-active-commit.xml: New
file.
* tests/qemuxml2xmltest.c (mymain): Drive new test.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
docs/formatdomain.html.in | 21 ++++++------
docs/schemas/domaincommon.rng | 13 ++++++++
src/conf/domain_conf.c | 33 ++++++++++++++++++-
src/conf/domain_conf.h | 1 +
src/qemu/qemu_driver.c | 3 ++
src/qemu/qemu_process.c | 18 +++++++----
.../qemuxml2argv-disk-active-commit.xml | 37 ++++++++++++++++++++++
.../qemuxml2argvdata/qemuxml2argv-disk-mirror.xml | 4 +--
.../qemuxml2xmlout-disk-mirror-old.xml | 4 +--
tests/qemuxml2xmltest.c | 1 +
10 files changed, 114 insertions(+), 21 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-active-commit.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 8950959..7593b55 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1898,16 +1898,19 @@
</dd>
<dt><code>mirror</code></dt>
<dd>
- This element is present if the hypervisor has started a block
- copy operation (via the <code>virDomainBlockRebase</code>
- API), where the mirror location in the <code>source</code>
- sub-element will eventually have the same contents as the
- source, and with the file format in the
+ This element is present if the hypervisor has started a
+ long-running block job operation, where the mirror location in
+ the <code>source</code> sub-element will eventually have the
+ same contents as the source, and with the file format in the
sub-element <code>format</code> (which might differ from the
- format of the source). The details of the <code>source</code>
- sub-element are determined by the <code>type</code> attribute
- of the mirror, similar to what is done for the
- overall <code>disk</code> device element. If
+ format of the source). The <code>job</code> attribute
+ mentions which API started the operation ("copy" for
+ the <code>virDomainBlockRebase</code> API, or "active-commit"
+ for the <code>virDomainBlockCommit</code>
+ API), <span class="since">since 1.2.7</span>. The details
+ of the <code>source</code> sub-element are determined by
+ the <code>type</code> attribute of the mirror, similar to what
+ is done for the overall <code>disk</code> device element. If
attribute <code>ready</code> is present, then it is known the
disk is ready to pivot; otherwise, the disk is probably still
copying. For now, this element only valid in output; it is
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 835bd3c..231c743 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4262,6 +4262,13 @@
</attribute>
</optional>
<optional>
+ <attribute name='job'>
+ <choice>
+ <value>copy</value>
+ </choice>
+ </attribute>
+ </optional>
+ <optional>
<interleave>
<ref name='diskSourceFile'/>
<optional>
@@ -4271,6 +4278,12 @@
</optional>
</group>
<group> <!-- preferred format -->
+ <attribute name='job'>
+ <choice>
+ <value>copy</value>
+ <value>active-commit</value>
+ </choice>
+ </attribute>
<interleave>
<ref name="diskSource"/>
<optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1e27165..4b00280 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -761,6 +761,12 @@ VIR_ENUM_IMPL(virDomainDiskDiscard, VIR_DOMAIN_DISK_DISCARD_LAST,
"unmap",
"ignore")
+/* Internal mapping: subset of block job types that can be present in
+ * <mirror> XML (remaining types are not two-phase). */
+VIR_ENUM_DECL(virDomainBlockJob)
+VIR_ENUM_IMPL(virDomainBlockJob, VIR_DOMAIN_BLOCK_JOB_TYPE_LAST,
+ "", "", "copy", "", "active-commit")
+
#define VIR_DOMAIN_XML_WRITE_FLAGS VIR_DOMAIN_XML_SECURE
#define VIR_DOMAIN_XML_READ_FLAGS VIR_DOMAIN_XML_INACTIVE
@@ -5406,10 +5412,26 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
xmlStrEqual(cur->name, BAD_CAST "mirror") &&
!(flags & VIR_DOMAIN_XML_INACTIVE)) {
char *ready;
+ char *blockJob;
if (VIR_ALLOC(def->mirror) < 0)
goto error;
+ blockJob = virXMLPropString(cur, "job");
+ if (blockJob) {
+ def->mirrorJob = virDomainBlockJobTypeFromString(blockJob);
+ if (def->mirrorJob <= 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown mirror job type '%s'"),
+ blockJob);
+ VIR_FREE(blockJob);
+ goto error;
+ }
+ VIR_FREE(blockJob);
+ } else {
+ def->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_COPY;
+ }
+
mirrorType = virXMLPropString(cur, "type");
if (mirrorType) {
def->mirror->type = virStorageTypeFromString(mirrorType);
@@ -5432,6 +5454,12 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
_("mirror requires file name"));
goto error;
}
+ if (def->mirrorJob != VIR_DOMAIN_BLOCK_JOB_TYPE_COPY) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("mirror without type only supported "
+ "by copy job"));
+ goto error;
+ }
mirrorFormat = virXMLPropString(cur, "format");
}
if (mirrorFormat) {
@@ -15163,10 +15191,13 @@ virDomainDiskDefFormat(virBufferPtr buf,
formatStr = virStorageFileFormatTypeToString(def->mirror->format);
virBufferAsprintf(buf, "<mirror type='%s'",
virStorageTypeToString(def->mirror->type));
- if (def->mirror->type == VIR_STORAGE_TYPE_FILE) {
+ if (def->mirror->type == VIR_STORAGE_TYPE_FILE &&
+ def->mirrorJob == VIR_DOMAIN_BLOCK_JOB_TYPE_COPY) {
virBufferEscapeString(buf, " file='%s'", def->mirror->path);
virBufferEscapeString(buf, " format='%s'", formatStr);
}
+ virBufferEscapeString(buf, " job='%s'",
+ virDomainBlockJobTypeToString(def->mirrorJob));
if (def->mirroring)
virBufferAddLit(buf, " ready='yes'");
virBufferAddLit(buf, ">\n");
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index cd3293b..f5eb031 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -614,6 +614,7 @@ struct _virDomainDiskDef {
virStorageSourcePtr mirror;
bool mirroring;
+ int mirrorJob; /* virDomainBlockJobType */
struct {
unsigned int cylinders;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1782913..368e112 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14872,6 +14872,7 @@ qemuDomainBlockPivot(virConnectPtr conn,
disk->mirror = NULL;
disk->mirroring = false;
+ disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN;
cleanup:
/* revert to original disk def on failure */
@@ -15037,6 +15038,7 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
virStorageSourceFree(disk->mirror);
disk->mirror = NULL;
disk->mirroring = false;
+ disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN;
}
waitjob:
@@ -15325,6 +15327,7 @@ qemuDomainBlockCopy(virDomainObjPtr vm,
need_unlink = false;
disk->mirror = mirror;
mirror = NULL;
+ disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_COPY;
endjob:
if (need_unlink && unlink(dest))
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 8a6b384..65e9faf 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1023,28 +1023,32 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
if (disk) {
/* Have to generate two variants of the event for old vs. new
* client callbacks */
+ if (type == VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT &&
+ disk->mirrorJob == VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT)
+ type = disk->mirrorJob;
path = virDomainDiskGetSource(disk);
event = virDomainEventBlockJobNewFromObj(vm, path, type, status);
event2 = virDomainEventBlockJob2NewFromObj(vm, disk->dst, type,
status);
/* XXX If we completed a block pull or commit, then recompute
* the cached backing chain to match. Better would be storing
- * the chain ourselves rather than reprobing, but this
- * requires modifying domain_conf and our XML to fully track
- * the chain across libvirtd restarts. For that matter, if
- * qemu gains support for committing the active layer, we have
- * to update disk->src. */
+ * the chain ourselves rather than reprobing, but we haven't
+ * quite completed that conversion to use our XML tracking. */
if ((type == VIR_DOMAIN_BLOCK_JOB_TYPE_PULL ||
- type == VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT) &&
+ type == VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT ||
+ type == VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT) &&
status == VIR_DOMAIN_BLOCK_JOB_COMPLETED)
qemuDomainDetermineDiskChain(driver, vm, disk, true);
- if (disk->mirror && type == VIR_DOMAIN_BLOCK_JOB_TYPE_COPY) {
+ if (disk->mirror &&
+ (type == VIR_DOMAIN_BLOCK_JOB_TYPE_COPY ||
+ type == VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT)) {
if (status == VIR_DOMAIN_BLOCK_JOB_READY) {
disk->mirroring = true;
} else if (status == VIR_DOMAIN_BLOCK_JOB_FAILED) {
virStorageSourceFree(disk->mirror);
disk->mirror = NULL;
disk->mirroring = false;
+ disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN;
}
}
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-active-commit.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-active-commit.xml
new file mode 100644
index 0000000..6ba5724
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-active-commit.xml
@@ -0,0 +1,37 @@
+<domain type='qemu' id='1'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='qcow2'/>
+ <source file='/tmp/HostVG/QEMUGuest1-snap'/>
+ <backingStore type='block' index='1'>
+ <format type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <backingStore/>
+ </backingStore>
+ <mirror type='block' job='active-commit'>
+ <format type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ </mirror>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml
index 72b03c9..abec180 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml
@@ -17,7 +17,7 @@
<disk type='block' device='disk'>
<source dev='/dev/HostVG/QEMUGuest1'/>
<backingStore/>
- <mirror type='file' file='/dev/HostVG/QEMUGuest1Copy' ready='yes'>
+ <mirror type='file' file='/dev/HostVG/QEMUGuest1Copy' job='copy' ready='yes'>
<source file='/dev/HostVG/QEMUGuest1Copy'/>
</mirror>
<target dev='hda' bus='ide'/>
@@ -33,7 +33,7 @@
<disk type='file' device='disk'>
<source file='/tmp/data.img'/>
<backingStore/>
- <mirror type='file' file='/tmp/copy.img' format='qcow2'>
+ <mirror type='file' file='/tmp/copy.img' format='qcow2' job='copy'>
<format type='qcow2'/>
<source file='/tmp/copy.img'/>
</mirror>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml
index 72b03c9..abec180 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml
@@ -17,7 +17,7 @@
<disk type='block' device='disk'>
<source dev='/dev/HostVG/QEMUGuest1'/>
<backingStore/>
- <mirror type='file' file='/dev/HostVG/QEMUGuest1Copy' ready='yes'>
+ <mirror type='file' file='/dev/HostVG/QEMUGuest1Copy' job='copy' ready='yes'>
<source file='/dev/HostVG/QEMUGuest1Copy'/>
</mirror>
<target dev='hda' bus='ide'/>
@@ -33,7 +33,7 @@
<disk type='file' device='disk'>
<source file='/tmp/data.img'/>
<backingStore/>
- <mirror type='file' file='/tmp/copy.img' format='qcow2'>
+ <mirror type='file' file='/tmp/copy.img' format='qcow2' job='copy'>
<format type='qcow2'/>
<source file='/tmp/copy.img'/>
</mirror>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index cefe05b..8966b9a 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -229,6 +229,7 @@ mymain(void)
DO_TEST_DIFFERENT("disk-mirror-old");
DO_TEST_FULL("disk-mirror", false, WHEN_ACTIVE);
DO_TEST_FULL("disk-mirror", true, WHEN_INACTIVE);
+ DO_TEST_FULL("disk-active-commit", false, WHEN_ACTIVE);
DO_TEST("graphics-listen-network");
DO_TEST("graphics-vnc");
DO_TEST("graphics-vnc-websocket");
--
1.9.3
10 years, 4 months