[libvirt] [PATCH] Deprecate several CURRENT/LIVE/CONFIG enums
by Hu Tao
This patch deprecates following enums:
VIR_DOMAIN_MEM_CURRENT
VIR_DOMAIN_MEM_LIVE
VIR_DOMAIN_MEM_CONFIG
VIR_DOMAIN_VCPU_LIVE
VIR_DOMAIN_VCPU_CONFIG
VIR_DOMAIN_DEVICE_MODIFY_CURRENT
VIR_DOMAIN_DEVICE_MODIFY_LIVE
VIR_DOMAIN_DEVICE_MODIFY_CONFIG
And modify internal codes to use virDomainModifycationImpact.
---
include/libvirt/libvirt.h.in | 69 +++++++++++++++++++-------------
python/generator.py | 6 +++
src/esx/esx_driver.c | 8 ++--
src/libvirt.c | 36 ++++++++--------
src/openvz/openvz_driver.c | 8 ++--
src/qemu/qemu_driver.c | 90 +++++++++++++++++++++---------------------
src/test/test_driver.c | 32 +++++++-------
src/uml/uml_driver.c | 4 +-
src/vbox/vbox_tmpl.c | 20 +++++-----
tools/virsh.c | 52 ++++++++++++------------
10 files changed, 172 insertions(+), 153 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index df213f1..d0378c4 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -863,15 +863,6 @@ int virDomainGetMemoryParameters(virDomainPtr domain,
virTypedParameterPtr params,
int *nparams, unsigned int flags);
-/* Memory size modification flags. */
-typedef enum {
- VIR_DOMAIN_MEM_CURRENT = 0, /* affect current domain state */
- VIR_DOMAIN_MEM_LIVE = (1 << 0), /* affect active domain */
- VIR_DOMAIN_MEM_CONFIG = (1 << 1), /* affect next boot */
- VIR_DOMAIN_MEM_MAXIMUM = (1 << 2), /* affect Max rather than current */
-} virDomainMemoryModFlags;
-
-
/*
* Dynamic control of domains
*/
@@ -1027,16 +1018,6 @@ struct _virVcpuInfo {
};
typedef virVcpuInfo *virVcpuInfoPtr;
-/* Flags for controlling virtual CPU hot-plugging. */
-typedef enum {
- /* Must choose at least one of these two bits; SetVcpus can choose both */
- VIR_DOMAIN_VCPU_LIVE = (1 << 0), /* Affect active domain */
- VIR_DOMAIN_VCPU_CONFIG = (1 << 1), /* Affect next boot */
-
- /* Additional flags to be bit-wise OR'd in */
- VIR_DOMAIN_VCPU_MAXIMUM = (1 << 2), /* Max rather than current count */
-} virDomainVcpuFlags;
-
int virDomainSetVcpus (virDomainPtr domain,
unsigned int nvcpus);
int virDomainSetVcpusFlags (virDomainPtr domain,
@@ -1136,15 +1117,6 @@ int virDomainGetVcpus (virDomainPtr domain,
#define VIR_GET_CPUMAP(cpumaps,maplen,vcpu) &(cpumaps[(vcpu)*(maplen)])
-typedef enum {
-
- VIR_DOMAIN_DEVICE_MODIFY_CURRENT = 0, /* Modify device allocation based on current domain state */
- VIR_DOMAIN_DEVICE_MODIFY_LIVE = (1 << 0), /* Modify live device allocation */
- VIR_DOMAIN_DEVICE_MODIFY_CONFIG = (1 << 1), /* Modify persisted device allocation */
- VIR_DOMAIN_DEVICE_MODIFY_FORCE = (1 << 2), /* Forcibly modify device
- (ex. force eject a cdrom) */
-} virDomainDeviceModifyFlags;
-
int virDomainAttachDevice(virDomainPtr domain, const char *xml);
int virDomainDetachDevice(virDomainPtr domain, const char *xml);
@@ -2673,6 +2645,47 @@ typedef struct _virTypedParameter virMemoryParameter;
*/
typedef virMemoryParameter *virMemoryParameterPtr;
+/* Memory size modification flags.
+ *
+ * Provided for backwards compatibility; virDomainModificationImpact is
+ * the preferred enum since 0.9.3.
+ */
+typedef enum {
+ VIR_DOMAIN_MEM_CURRENT = VIR_DOMAIN_AFFECT_CURRENT,
+ VIR_DOMAIN_MEM_LIVE = VIR_DOMAIN_AFFECT_LIVE,
+ VIR_DOMAIN_MEM_CONFIG = VIR_DOMAIN_AFFECT_CONFIG,
+
+ VIR_DOMAIN_MEM_MAXIMUM = (1 << 2), /* affect Max rather than current */
+} virDomainMemoryModFlags;
+
+/* Device modification flags.
+ *
+ * Provided for backwards compatibility; virDomainModificationImpact is
+ * the preferred enum since 0.9.3.
+ */
+typedef enum {
+ VIR_DOMAIN_DEVICE_MODIFY_CURRENT = VIR_DOMAIN_AFFECT_CURRENT,
+ VIR_DOMAIN_DEVICE_MODIFY_LIVE = VIR_DOMAIN_AFFECT_LIVE,
+ VIR_DOMAIN_DEVICE_MODIFY_CONFIG = VIR_DOMAIN_AFFECT_CONFIG,
+
+ VIR_DOMAIN_DEVICE_MODIFY_FORCE = (1 << 2), /* Forcibly modify device
+ (ex. force eject a cdrom) */
+} virDomainDeviceModifyFlags;
+
+/* Flags for controlling virtual CPU hot-plugging.
+ *
+ * Provided for backwards compatibility; virDomainModificationImpact is
+ * the preferred enum since 0.9.3.
+ */
+typedef enum {
+ /* Must choose at least one of these two bits; SetVcpus can choose both */
+ VIR_DOMAIN_VCPU_LIVE = VIR_DOMAIN_AFFECT_LIVE,
+ VIR_DOMAIN_VCPU_CONFIG = VIR_DOMAIN_AFFECT_CONFIG,
+
+ /* Additional flags to be bit-wise OR'd in */
+ VIR_DOMAIN_VCPU_MAXIMUM = (1 << 2), /* Max rather than current count */
+} virDomainVcpuFlags;
+
#ifdef __cplusplus
}
#endif
diff --git a/python/generator.py b/python/generator.py
index 7c38fdd..2cbe168 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -166,6 +166,12 @@ def enum(type, name, value):
value = 5
elif value == 'VIR_TYPED_PARAM_BOOLEAN':
value = 6
+ elif value == 'VIR_DOMAIN_AFFECT_CURRENT':
+ value = 0
+ elif value == 'VIR_DOMAIN_AFFECT_LIVE':
+ value = 1
+ elif value == 'VIR_DOMAIN_AFFECT_CONFIG':
+ value = 2
enums[type][name] = value
#######################################################################
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index a5b96a9..3a140e9 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -2535,7 +2535,7 @@ esxDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
esxVI_TaskInfoState taskInfoState;
char *taskInfoErrorMessage = NULL;
- if (flags != VIR_DOMAIN_VCPU_LIVE) {
+ if (flags != VIR_DOMAIN_AFFECT_LIVE) {
ESX_ERROR(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
return -1;
}
@@ -2606,7 +2606,7 @@ esxDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
static int
esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
{
- return esxDomainSetVcpusFlags(domain, nvcpus, VIR_DOMAIN_VCPU_LIVE);
+ return esxDomainSetVcpusFlags(domain, nvcpus, VIR_DOMAIN_AFFECT_LIVE);
}
@@ -2619,7 +2619,7 @@ esxDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
esxVI_ObjectContent *hostSystem = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL;
- if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
+ if (flags != (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
ESX_ERROR(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
return -1;
}
@@ -2674,7 +2674,7 @@ esxDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
static int
esxDomainGetMaxVcpus(virDomainPtr domain)
{
- return esxDomainGetVcpusFlags(domain, (VIR_DOMAIN_VCPU_LIVE |
+ return esxDomainGetVcpusFlags(domain, (VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_VCPU_MAXIMUM));
}
diff --git a/src/libvirt.c b/src/libvirt.c
index 18c4e08..463c033 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -2865,12 +2865,12 @@ error:
* to Domain0 i.e. the domain where the application runs.
* This function may requires privileged access to the hypervisor.
*
- * @flags may include VIR_DOMAIN_MEM_LIVE or VIR_DOMAIN_MEM_CONFIG.
- * Both flags may be set. If VIR_DOMAIN_MEM_LIVE is set, the change affects
+ * @flags may include VIR_DOMAIN_AFFECT_LIVE or VIR_DOMAIN_AFFECT_CONFIG.
+ * Both flags may be set. If VIR_DOMAIN_AFFECT_LIVE is set, the change affects
* a running domain and will fail if domain is not active.
- * If VIR_DOMAIN_MEM_CONFIG is set, the change affects persistent state,
+ * If VIR_DOMAIN_AFFECT_CONFIG is set, the change affects persistent state,
* and will fail for transient domains. If neither flag is specified
- * (that is, @flags is VIR_DOMAIN_MEM_CURRENT), then an inactive domain
+ * (that is, @flags is VIR_DOMAIN_AFFECT_CURRENT), then an inactive domain
* modifies persistent setup, while an active domain is hypervisor-dependent
* on whether just live or both live and persistent state is changed.
* If VIR_DOMAIN_MEM_MAXIMUM is set, the change affects domain's maximum memory
@@ -6514,13 +6514,13 @@ error:
* does not support it or if growing the number is arbitrary limited.
* This function requires privileged access to the hypervisor.
*
- * @flags must include VIR_DOMAIN_VCPU_LIVE to affect a running
+ * @flags must include VIR_DOMAIN_AFFECT_LIVE to affect a running
* domain (which may fail if domain is not active), or
- * VIR_DOMAIN_VCPU_CONFIG to affect the next boot via the XML
+ * VIR_DOMAIN_AFFECT_CONFIG to affect the next boot via the XML
* description of the domain. Both flags may be set.
*
* If @flags includes VIR_DOMAIN_VCPU_MAXIMUM, then
- * VIR_DOMAIN_VCPU_LIVE must be clear, and only the maximum virtual
+ * VIR_DOMAIN_AFFECT_LIVE must be clear, and only the maximum virtual
* CPU limit is altered; generally, this value must be less than or
* equal to virConnectGetMaxVcpus(). Otherwise, this call affects the
* current virtual CPU limit, which must be less than or equal to the
@@ -6551,7 +6551,7 @@ virDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
/* Perform some argument validation common to all implementations. */
if (nvcpus < 1 || (unsigned short) nvcpus != nvcpus ||
- (flags & (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_CONFIG)) == 0) {
+ (flags & (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG)) == 0) {
virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
goto error;
}
@@ -6610,7 +6610,7 @@ virDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
}
/* Exactly one of these two flags should be set. */
- if (!(flags & VIR_DOMAIN_VCPU_LIVE) == !(flags & VIR_DOMAIN_VCPU_CONFIG)) {
+ if (!(flags & VIR_DOMAIN_AFFECT_LIVE) == !(flags & VIR_DOMAIN_AFFECT_CONFIG)) {
virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
goto error;
}
@@ -6958,11 +6958,11 @@ error:
* @flags: an OR'ed set of virDomainDeviceModifyFlags
*
* Attach a virtual device to a domain, using the flags parameter
- * to control how the device is attached. VIR_DOMAIN_DEVICE_MODIFY_CURRENT
+ * to control how the device is attached. VIR_DOMAIN_AFFECT_CURRENT
* specifies that the device allocation is made based on current domain
- * state. VIR_DOMAIN_DEVICE_MODIFY_LIVE specifies that the device shall be
+ * state. VIR_DOMAIN_AFFECT_LIVE specifies that the device shall be
* allocated to the active domain instance only and is not added to the
- * persisted domain configuration. VIR_DOMAIN_DEVICE_MODIFY_CONFIG
+ * persisted domain configuration. VIR_DOMAIN_AFFECT_CONFIG
* specifies that the device shall be allocated to the persisted domain
* configuration only. Note that the target hypervisor must return an
* error if unable to satisfy flags. E.g. the hypervisor driver will
@@ -7075,11 +7075,11 @@ error:
* @flags: an OR'ed set of virDomainDeviceModifyFlags
*
* Detach a virtual device from a domain, using the flags parameter
- * to control how the device is detached. VIR_DOMAIN_DEVICE_MODIFY_CURRENT
+ * to control how the device is detached. VIR_DOMAIN_AFFECT_CURRENT
* specifies that the device allocation is removed based on current domain
- * state. VIR_DOMAIN_DEVICE_MODIFY_LIVE specifies that the device shall be
+ * state. VIR_DOMAIN_AFFECT_LIVE specifies that the device shall be
* deallocated from the active domain instance only and is not from the
- * persisted domain configuration. VIR_DOMAIN_DEVICE_MODIFY_CONFIG
+ * persisted domain configuration. VIR_DOMAIN_AFFECT_CONFIG
* specifies that the device shall be deallocated from the persisted domain
* configuration only. Note that the target hypervisor must return an
* error if unable to satisfy flags. E.g. the hypervisor driver will
@@ -7137,11 +7137,11 @@ error:
* @flags: an OR'ed set of virDomainDeviceModifyFlags
*
* Change a virtual device on a domain, using the flags parameter
- * to control how the device is changed. VIR_DOMAIN_DEVICE_MODIFY_CURRENT
+ * to control how the device is changed. VIR_DOMAIN_AFFECT_CURRENT
* specifies that the device change is made based on current domain
- * state. VIR_DOMAIN_DEVICE_MODIFY_LIVE specifies that the device shall be
+ * state. VIR_DOMAIN_AFFECT_LIVE specifies that the device shall be
* changed on the active domain instance only and is not added to the
- * persisted domain configuration. VIR_DOMAIN_DEVICE_MODIFY_CONFIG
+ * persisted domain configuration. VIR_DOMAIN_AFFECT_CONFIG
* specifies that the device shall be changed on the persisted domain
* configuration only. Note that the target hypervisor must return an
* error if unable to satisfy flags. E.g. the hypervisor driver will
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index e24b5d8..645e426 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1200,7 +1200,7 @@ static int
openvzDomainGetVcpusFlags(virDomainPtr dom ATTRIBUTE_UNUSED,
unsigned int flags)
{
- if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
+ if (flags != (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
openvzError(VIR_ERR_INVALID_ARG, _("unsupported flags (0x%x)"), flags);
return -1;
}
@@ -1210,7 +1210,7 @@ openvzDomainGetVcpusFlags(virDomainPtr dom ATTRIBUTE_UNUSED,
static int openvzDomainGetMaxVcpus(virDomainPtr dom)
{
- return openvzDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_LIVE |
+ return openvzDomainGetVcpusFlags(dom, (VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_VCPU_MAXIMUM));
}
@@ -1244,7 +1244,7 @@ static int openvzDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
struct openvz_driver *driver = dom->conn->privateData;
int ret = -1;
- if (flags != VIR_DOMAIN_VCPU_LIVE) {
+ if (flags != VIR_DOMAIN_AFFECT_LIVE) {
openvzError(VIR_ERR_INVALID_ARG, _("unsupported flags (0x%x)"), flags);
return -1;
}
@@ -1277,7 +1277,7 @@ cleanup:
static int
openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
{
- return openvzDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_VCPU_LIVE);
+ return openvzDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_AFFECT_LIVE);
}
static virDrvOpenStatus openvzOpen(virConnectPtr conn,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 80de79a..8083707 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1595,8 +1595,8 @@ static int qemudDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
int ret = -1, r;
bool isActive;
- virCheckFlags(VIR_DOMAIN_MEM_LIVE |
- VIR_DOMAIN_MEM_CONFIG |
+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+ VIR_DOMAIN_AFFECT_CONFIG |
VIR_DOMAIN_MEM_MAXIMUM, -1);
qemuDriverLock(driver);
@@ -1615,26 +1615,26 @@ static int qemudDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
isActive = virDomainObjIsActive(vm);
- if (flags == VIR_DOMAIN_MEM_CURRENT) {
+ if (flags == VIR_DOMAIN_AFFECT_CURRENT) {
if (isActive)
- flags = VIR_DOMAIN_MEM_LIVE;
+ flags = VIR_DOMAIN_AFFECT_LIVE;
else
- flags = VIR_DOMAIN_MEM_CONFIG;
+ flags = VIR_DOMAIN_AFFECT_CONFIG;
}
if (flags == VIR_DOMAIN_MEM_MAXIMUM) {
if (isActive)
- flags = VIR_DOMAIN_MEM_LIVE | VIR_DOMAIN_MEM_MAXIMUM;
+ flags = VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_MEM_MAXIMUM;
else
- flags = VIR_DOMAIN_MEM_CONFIG | VIR_DOMAIN_MEM_MAXIMUM;
+ flags = VIR_DOMAIN_AFFECT_CONFIG | VIR_DOMAIN_MEM_MAXIMUM;
}
- if (!isActive && (flags & VIR_DOMAIN_MEM_LIVE)) {
+ if (!isActive && (flags & VIR_DOMAIN_AFFECT_LIVE)) {
qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
goto endjob;
}
- if (flags & VIR_DOMAIN_MEM_CONFIG) {
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
if (!vm->persistent) {
qemuReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot change persistent config of a transient domain"));
@@ -1647,14 +1647,14 @@ static int qemudDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
if (flags & VIR_DOMAIN_MEM_MAXIMUM) {
/* resize the maximum memory */
- if (flags & VIR_DOMAIN_MEM_LIVE) {
+ if (flags & VIR_DOMAIN_AFFECT_LIVE) {
qemuReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot resize the maximum memory on an "
"active domain"));
goto endjob;
}
- if (flags & VIR_DOMAIN_MEM_CONFIG) {
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
/* Help clang 2.8 decipher the logic flow. */
sa_assert(persistentDef);
persistentDef->mem.max_balloon = newmem;
@@ -1673,7 +1673,7 @@ static int qemudDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
goto endjob;
}
- if (flags & VIR_DOMAIN_MEM_LIVE) {
+ if (flags & VIR_DOMAIN_AFFECT_LIVE) {
priv = vm->privateData;
qemuDomainObjEnterMonitor(vm);
r = qemuMonitorSetBalloon(priv->mon, newmem);
@@ -1691,7 +1691,7 @@ static int qemudDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
}
}
- if (flags & VIR_DOMAIN_MEM_CONFIG) {
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
sa_assert(persistentDef);
persistentDef->mem.cur_balloon = newmem;
ret = virDomainSaveConfig(driver->configDir, persistentDef);
@@ -1712,7 +1712,7 @@ cleanup:
static int qemudDomainSetMemory(virDomainPtr dom, unsigned long newmem)
{
- return qemudDomainSetMemoryFlags(dom, newmem, VIR_DOMAIN_MEM_LIVE);
+ return qemudDomainSetMemoryFlags(dom, newmem, VIR_DOMAIN_AFFECT_LIVE);
}
static int qemudDomainSetMaxMemory(virDomainPtr dom, unsigned long memory)
@@ -2760,15 +2760,15 @@ qemudDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
int max;
int ret = -1;
- virCheckFlags(VIR_DOMAIN_VCPU_LIVE |
- VIR_DOMAIN_VCPU_CONFIG |
+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+ VIR_DOMAIN_AFFECT_CONFIG |
VIR_DOMAIN_VCPU_MAXIMUM, -1);
/* At least one of LIVE or CONFIG must be set. MAXIMUM cannot be
* mixed with LIVE. */
- if ((flags & (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_CONFIG)) == 0 ||
- (flags & (VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_LIVE)) ==
- (VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_LIVE)) {
+ if ((flags & (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG)) == 0 ||
+ (flags & (VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_AFFECT_LIVE)) ==
+ (VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_AFFECT_LIVE)) {
qemuReportError(VIR_ERR_INVALID_ARG,
_("invalid flag combination: (0x%x)"), flags);
return -1;
@@ -2794,13 +2794,13 @@ qemudDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
if (qemuDomainObjBeginJob(vm) < 0)
goto cleanup;
- if (!virDomainObjIsActive(vm) && (flags & VIR_DOMAIN_VCPU_LIVE)) {
+ if (!virDomainObjIsActive(vm) && (flags & VIR_DOMAIN_AFFECT_LIVE)) {
qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
goto endjob;
}
- if (!vm->persistent && (flags & VIR_DOMAIN_VCPU_CONFIG)) {
+ if (!vm->persistent && (flags & VIR_DOMAIN_AFFECT_CONFIG)) {
qemuReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot change persistent config of a transient domain"));
goto endjob;
@@ -2834,23 +2834,23 @@ qemudDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
goto endjob;
switch (flags) {
- case VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_CONFIG:
+ case VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_AFFECT_CONFIG:
persistentDef->maxvcpus = nvcpus;
if (nvcpus < persistentDef->vcpus)
persistentDef->vcpus = nvcpus;
ret = 0;
break;
- case VIR_DOMAIN_VCPU_CONFIG:
+ case VIR_DOMAIN_AFFECT_CONFIG:
persistentDef->vcpus = nvcpus;
ret = 0;
break;
- case VIR_DOMAIN_VCPU_LIVE:
+ case VIR_DOMAIN_AFFECT_LIVE:
ret = qemudDomainHotplugVcpus(vm, nvcpus);
break;
- case VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_CONFIG:
+ case VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG:
ret = qemudDomainHotplugVcpus(vm, nvcpus);
if (ret == 0) {
persistentDef->vcpus = nvcpus;
@@ -2859,7 +2859,7 @@ qemudDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
}
/* Save the persistent config to disk */
- if (flags & VIR_DOMAIN_VCPU_CONFIG)
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG)
ret = virDomainSaveConfig(driver->configDir, persistentDef);
endjob:
@@ -2875,7 +2875,7 @@ cleanup:
static int
qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
{
- return qemudDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_VCPU_LIVE);
+ return qemudDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_AFFECT_LIVE);
}
@@ -3049,12 +3049,12 @@ qemudDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
virDomainDefPtr def;
int ret = -1;
- virCheckFlags(VIR_DOMAIN_VCPU_LIVE |
- VIR_DOMAIN_VCPU_CONFIG |
+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+ VIR_DOMAIN_AFFECT_CONFIG |
VIR_DOMAIN_VCPU_MAXIMUM, -1);
/* Exactly one of LIVE or CONFIG must be set. */
- if (!(flags & VIR_DOMAIN_VCPU_LIVE) == !(flags & VIR_DOMAIN_VCPU_CONFIG)) {
+ if (!(flags & VIR_DOMAIN_AFFECT_LIVE) == !(flags & VIR_DOMAIN_AFFECT_CONFIG)) {
qemuReportError(VIR_ERR_INVALID_ARG,
_("invalid flag combination: (0x%x)"), flags);
return -1;
@@ -3072,7 +3072,7 @@ qemudDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
goto cleanup;
}
- if (flags & VIR_DOMAIN_VCPU_LIVE) {
+ if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (!virDomainObjIsActive(vm)) {
qemuReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("domain not active"));
@@ -3094,7 +3094,7 @@ cleanup:
static int
qemudDomainGetMaxVcpus(virDomainPtr dom)
{
- return qemudDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_LIVE |
+ return qemudDomainGetVcpusFlags(dom, (VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_VCPU_MAXIMUM));
}
@@ -4458,8 +4458,8 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
bool force = (flags & VIR_DOMAIN_DEVICE_MODIFY_FORCE) != 0;
int ret = -1;
- virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE |
- VIR_DOMAIN_DEVICE_MODIFY_CONFIG |
+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+ VIR_DOMAIN_AFFECT_CONFIG |
(action == QEMU_DEVICE_UPDATE ?
VIR_DOMAIN_DEVICE_MODIFY_FORCE : 0), -1);
@@ -4477,13 +4477,13 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
goto cleanup;
if (virDomainObjIsActive(vm)) {
- if (flags == VIR_DOMAIN_DEVICE_MODIFY_CURRENT)
- flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
+ if (flags == VIR_DOMAIN_AFFECT_CURRENT)
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
} else {
- if (flags == VIR_DOMAIN_DEVICE_MODIFY_CURRENT)
- flags |= VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
+ if (flags == VIR_DOMAIN_AFFECT_CURRENT)
+ flags |= VIR_DOMAIN_AFFECT_CONFIG;
/* check consistency between flags and the vm state */
- if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
+ if (flags & VIR_DOMAIN_AFFECT_LIVE) {
qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s",
_("cannot do live update a device on "
@@ -4492,13 +4492,13 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
}
}
- if ((flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) && !vm->persistent) {
+ if ((flags & VIR_DOMAIN_AFFECT_CONFIG) && !vm->persistent) {
qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot modify device on transient domain"));
goto endjob;
}
- if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
dev = virDomainDeviceDefParse(driver->caps, vm->def, xml,
VIR_DOMAIN_XML_INACTIVE);
if (dev == NULL)
@@ -4526,7 +4526,7 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
} else
ret = 0;
- if (!ret && (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE)) {
+ if (!ret && (flags & VIR_DOMAIN_AFFECT_LIVE)) {
/* If dev exists it was created to modify the domain config. Free it. */
virDomainDeviceDefFree(dev);
dev = virDomainDeviceDefParse(driver->caps, vm->def, xml,
@@ -4558,7 +4558,7 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
ret = -1;
}
/* Finally, if no error until here, we can save config. */
- if (!ret && (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG)) {
+ if (!ret && (flags & VIR_DOMAIN_AFFECT_CONFIG)) {
ret = virDomainSaveConfig(driver->configDir, vmdef);
if (!ret) {
virDomainObjAssignDef(vm, vmdef, false);
@@ -4588,7 +4588,7 @@ static int qemuDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
static int qemuDomainAttachDevice(virDomainPtr dom, const char *xml)
{
return qemuDomainAttachDeviceFlags(dom, xml,
- VIR_DOMAIN_DEVICE_MODIFY_LIVE);
+ VIR_DOMAIN_AFFECT_LIVE);
}
@@ -4608,7 +4608,7 @@ static int qemuDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
static int qemuDomainDetachDevice(virDomainPtr dom, const char *xml)
{
return qemuDomainDetachDeviceFlags(dom, xml,
- VIR_DOMAIN_DEVICE_MODIFY_LIVE);
+ VIR_DOMAIN_AFFECT_LIVE);
}
static int qemudDomainGetAutostart(virDomainPtr dom,
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 2da24f1..efb75c7 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2066,12 +2066,12 @@ testDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
virDomainDefPtr def;
int ret = -1;
- virCheckFlags(VIR_DOMAIN_VCPU_LIVE |
- VIR_DOMAIN_VCPU_CONFIG |
+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+ VIR_DOMAIN_AFFECT_CONFIG |
VIR_DOMAIN_VCPU_MAXIMUM, -1);
/* Exactly one of LIVE or CONFIG must be set. */
- if (!(flags & VIR_DOMAIN_VCPU_LIVE) == !(flags & VIR_DOMAIN_VCPU_CONFIG)) {
+ if (!(flags & VIR_DOMAIN_AFFECT_LIVE) == !(flags & VIR_DOMAIN_AFFECT_CONFIG)) {
testError(VIR_ERR_INVALID_ARG,
_("invalid flag combination: (0x%x)"), flags);
return -1;
@@ -2089,7 +2089,7 @@ testDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
goto cleanup;
}
- if (flags & VIR_DOMAIN_VCPU_LIVE) {
+ if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (!virDomainObjIsActive(vm)) {
testError(VIR_ERR_OPERATION_INVALID, "%s",
_("domain not active"));
@@ -2111,7 +2111,7 @@ cleanup:
static int
testDomainGetMaxVcpus(virDomainPtr domain)
{
- return testDomainGetVcpusFlags(domain, (VIR_DOMAIN_VCPU_LIVE |
+ return testDomainGetVcpusFlags(domain, (VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_VCPU_MAXIMUM));
}
@@ -2124,15 +2124,15 @@ testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus,
virDomainDefPtr persistentDef;
int ret = -1, maxvcpus;
- virCheckFlags(VIR_DOMAIN_VCPU_LIVE |
- VIR_DOMAIN_VCPU_CONFIG |
+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+ VIR_DOMAIN_AFFECT_CONFIG |
VIR_DOMAIN_VCPU_MAXIMUM, -1);
/* At least one of LIVE or CONFIG must be set. MAXIMUM cannot be
* mixed with LIVE. */
- if ((flags & (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_CONFIG)) == 0 ||
- (flags & (VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_LIVE)) ==
- (VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_LIVE)) {
+ if ((flags & (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG)) == 0 ||
+ (flags & (VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_AFFECT_LIVE)) ==
+ (VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_AFFECT_LIVE)) {
testError(VIR_ERR_INVALID_ARG,
_("invalid flag combination: (0x%x)"), flags);
return -1;
@@ -2152,7 +2152,7 @@ testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus,
goto cleanup;
}
- if (!virDomainObjIsActive(privdom) && (flags & VIR_DOMAIN_VCPU_LIVE)) {
+ if (!virDomainObjIsActive(privdom) && (flags & VIR_DOMAIN_AFFECT_LIVE)) {
testError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot hotplug vcpus for an inactive domain"));
goto cleanup;
@@ -2176,23 +2176,23 @@ testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus,
goto cleanup;
switch (flags) {
- case VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_CONFIG:
+ case VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_AFFECT_CONFIG:
persistentDef->maxvcpus = nrCpus;
if (nrCpus < persistentDef->vcpus)
persistentDef->vcpus = nrCpus;
ret = 0;
break;
- case VIR_DOMAIN_VCPU_CONFIG:
+ case VIR_DOMAIN_AFFECT_CONFIG:
persistentDef->vcpus = nrCpus;
ret = 0;
break;
- case VIR_DOMAIN_VCPU_LIVE:
+ case VIR_DOMAIN_AFFECT_LIVE:
ret = testDomainUpdateVCPUs(domain->conn, privdom, nrCpus, 0);
break;
- case VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_CONFIG:
+ case VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG:
ret = testDomainUpdateVCPUs(domain->conn, privdom, nrCpus, 0);
if (ret == 0) {
persistentDef->vcpus = nrCpus;
@@ -2209,7 +2209,7 @@ cleanup:
static int
testSetVcpus(virDomainPtr domain, unsigned int nrCpus)
{
- return testDomainSetVcpusFlags(domain, nrCpus, VIR_DOMAIN_VCPU_LIVE);
+ return testDomainSetVcpusFlags(domain, nrCpus, VIR_DOMAIN_AFFECT_LIVE);
}
static int testDomainGetVcpus(virDomainPtr domain,
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 536cd8c..4427e95 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -1831,7 +1831,7 @@ cleanup:
static int umlDomainAttachDeviceFlags(virDomainPtr dom,
const char *xml,
unsigned int flags) {
- if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
umlReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot modify the persistent configuration of a domain"));
return -1;
@@ -1939,7 +1939,7 @@ cleanup:
static int umlDomainDetachDeviceFlags(virDomainPtr dom,
const char *xml,
unsigned int flags) {
- if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
umlReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot modify the persistent configuration of a domain"));
return -1;
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 2986f5a..f2233a5 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -2044,7 +2044,7 @@ vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
PRUint32 CPUCount = nvcpus;
nsresult rc;
- if (flags != VIR_DOMAIN_VCPU_LIVE) {
+ if (flags != VIR_DOMAIN_AFFECT_LIVE) {
vboxError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
return -1;
}
@@ -2092,7 +2092,7 @@ vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
static int
vboxDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
{
- return vboxDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_VCPU_LIVE);
+ return vboxDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_AFFECT_LIVE);
}
static int
@@ -2102,7 +2102,7 @@ vboxDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
ISystemProperties *systemProperties = NULL;
PRUint32 maxCPUCount = 0;
- if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
+ if (flags != (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
vboxError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
return -1;
}
@@ -2127,7 +2127,7 @@ vboxDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
static int
vboxDomainGetMaxVcpus(virDomainPtr dom)
{
- return vboxDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_LIVE |
+ return vboxDomainGetVcpusFlags(dom, (VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_VCPU_MAXIMUM));
}
@@ -5292,7 +5292,7 @@ static int vboxDomainAttachDevice(virDomainPtr dom, const char *xml) {
static int vboxDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
unsigned int flags) {
- if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
vboxError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot modify the persistent configuration of a domain"));
return -1;
@@ -5303,11 +5303,11 @@ static int vboxDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
static int vboxDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
unsigned int flags) {
- virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_CURRENT |
- VIR_DOMAIN_DEVICE_MODIFY_LIVE |
- VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1);
+ virCheckFlags(VIR_DOMAIN_AFFECT_CURRENT |
+ VIR_DOMAIN_AFFECT_LIVE |
+ VIR_DOMAIN_AFFECT_CONFIG, -1);
- if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
vboxError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot modify the persistent configuration of a domain"));
return -1;
@@ -5442,7 +5442,7 @@ cleanup:
static int vboxDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
unsigned int flags) {
- if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
vboxError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot modify the persistent configuration of a domain"));
return -1;
diff --git a/tools/virsh.c b/tools/virsh.c
index d98be1c..5663f3f 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2718,7 +2718,7 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
* up. */
if (all || (maximum && config)) {
count = virDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_MAXIMUM |
- VIR_DOMAIN_VCPU_CONFIG));
+ VIR_DOMAIN_AFFECT_CONFIG));
if (count < 0 && (last_error->code == VIR_ERR_NO_SUPPORT
|| last_error->code == VIR_ERR_INVALID_ARG)) {
char *tmp;
@@ -2748,7 +2748,7 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
if (all || (maximum && live)) {
count = virDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_MAXIMUM |
- VIR_DOMAIN_VCPU_LIVE));
+ VIR_DOMAIN_AFFECT_LIVE));
if (count < 0 && (last_error->code == VIR_ERR_NO_SUPPORT
|| last_error->code == VIR_ERR_INVALID_ARG)) {
count = virDomainGetMaxVcpus(dom);
@@ -2768,7 +2768,7 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
}
if (all || (current && config)) {
- count = virDomainGetVcpusFlags(dom, VIR_DOMAIN_VCPU_CONFIG);
+ count = virDomainGetVcpusFlags(dom, VIR_DOMAIN_AFFECT_CONFIG);
if (count < 0 && (last_error->code == VIR_ERR_NO_SUPPORT
|| last_error->code == VIR_ERR_INVALID_ARG)) {
char *tmp, *end;
@@ -2805,7 +2805,7 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
}
if (all || (current && live)) {
- count = virDomainGetVcpusFlags(dom, VIR_DOMAIN_VCPU_LIVE);
+ count = virDomainGetVcpusFlags(dom, VIR_DOMAIN_AFFECT_LIVE);
if (count < 0 && (last_error->code == VIR_ERR_NO_SUPPORT
|| last_error->code == VIR_ERR_INVALID_ARG)) {
virDomainInfo info;
@@ -3078,8 +3078,8 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
int config = vshCommandOptBool(cmd, "config");
int live = vshCommandOptBool(cmd, "live");
int flags = ((maximum ? VIR_DOMAIN_VCPU_MAXIMUM : 0) |
- (config ? VIR_DOMAIN_VCPU_CONFIG : 0) |
- (live ? VIR_DOMAIN_VCPU_LIVE : 0));
+ (config ? VIR_DOMAIN_AFFECT_CONFIG : 0) |
+ (live ? VIR_DOMAIN_AFFECT_LIVE : 0));
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
@@ -3195,12 +3195,12 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd)
vshError(ctl, "%s", _("--current must be specified exclusively"));
return false;
}
- flags = VIR_DOMAIN_MEM_CURRENT;
+ flags = VIR_DOMAIN_AFFECT_CURRENT;
} else {
if (config)
- flags |= VIR_DOMAIN_MEM_CONFIG;
+ flags |= VIR_DOMAIN_AFFECT_CONFIG;
if (live)
- flags |= VIR_DOMAIN_MEM_LIVE;
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
/* neither option is specified */
if (!live && !config)
flags = -1;
@@ -3286,9 +3286,9 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd)
}
} else {
if (config)
- flags |= VIR_DOMAIN_MEM_CONFIG;
+ flags |= VIR_DOMAIN_AFFECT_CONFIG;
if (live)
- flags |= VIR_DOMAIN_MEM_LIVE;
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
/* neither option is specified */
if (!live && !config)
flags = -1;
@@ -9281,9 +9281,9 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
}
if (vshCommandOptBool(cmd, "persistent")) {
- flags = VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
+ flags = VIR_DOMAIN_AFFECT_CONFIG;
if (virDomainIsActive(dom) == 1)
- flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
ret = virDomainAttachDeviceFlags(dom, buffer, flags);
} else {
ret = virDomainAttachDevice(dom, buffer);
@@ -9346,9 +9346,9 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
}
if (vshCommandOptBool(cmd, "persistent")) {
- flags = VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
+ flags = VIR_DOMAIN_AFFECT_CONFIG;
if (virDomainIsActive(dom) == 1)
- flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
ret = virDomainDetachDeviceFlags(dom, buffer, flags);
} else {
ret = virDomainDetachDevice(dom, buffer);
@@ -9412,11 +9412,11 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd)
}
if (vshCommandOptBool(cmd, "persistent")) {
- flags = VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
+ flags = VIR_DOMAIN_AFFECT_CONFIG;
if (virDomainIsActive(dom) == 1)
- flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
} else {
- flags = VIR_DOMAIN_DEVICE_MODIFY_LIVE;
+ flags = VIR_DOMAIN_AFFECT_LIVE;
}
if (vshCommandOptBool(cmd, "force"))
@@ -9528,9 +9528,9 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
xml = virBufferContentAndReset(&buf);
if (vshCommandOptBool(cmd, "persistent")) {
- flags = VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
+ flags = VIR_DOMAIN_AFFECT_CONFIG;
if (virDomainIsActive(dom) == 1)
- flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
ret = virDomainAttachDeviceFlags(dom, xml, flags);
} else {
ret = virDomainAttachDevice(dom, xml);
@@ -9667,9 +9667,9 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
}
if (vshCommandOptBool(cmd, "persistent")) {
- flags = VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
+ flags = VIR_DOMAIN_AFFECT_CONFIG;
if (virDomainIsActive(dom) == 1)
- flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
ret = virDomainDetachDeviceFlags(dom,
(char *)xmlBufferContent(xml_buf),
flags);
@@ -9805,9 +9805,9 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
xml = virBufferContentAndReset(&buf);
if (vshCommandOptBool(cmd, "persistent")) {
- flags = VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
+ flags = VIR_DOMAIN_AFFECT_CONFIG;
if (virDomainIsActive(dom) == 1)
- flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
ret = virDomainAttachDeviceFlags(dom, xml, flags);
} else {
ret = virDomainAttachDevice(dom, xml);
@@ -9927,9 +9927,9 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
}
if (vshCommandOptBool(cmd, "persistent")) {
- flags = VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
+ flags = VIR_DOMAIN_AFFECT_CONFIG;
if (virDomainIsActive(dom) == 1)
- flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
ret = virDomainDetachDeviceFlags(dom,
(char *)xmlBufferContent(xml_buf),
flags);
--
1.7.3.1
13 years, 10 months
[libvirt] RFC (v4): Add virDomainBlockPull API family to libvirt
by Adam Litke
This round addresses all review comments from the last posting and should be
ready for inclusion. Thanks for the review.
Changes since V3:
- Don't check flags at the libvirt API level
- qemu: Check disk->type before looking up alias
- virsh: Merge blockpullall into blockpull
- event: Drop events for unknown disk paths
- Misc style fixes and comment updates
Changes since V2:
- Rebased
- Ensure error messages are consistent between JSON and Text interfaces
- Added additional tests to the sample test bucket
Changes since V1:
- Rebased to incorporate changes to generator and
removal of static driver structure initializers
- Other small fixups suggested by Matthias Bolte
To help speed the provisioning process for large domains, new QED disks are
created with backing to a template image. These disks are configured with copy
on read such that blocks that are read from the backing file are copied to the
new disk. This reduces I/O over a potentially costly path to the backing
image.
In such a configuration, there is a desire to remove the dependency on the
backing image as the domain runs. To accomplish this, qemu will provide an
interface to perform sequential copy on read operations during normal VM
operation. Once all data has been copied, the disk image's link to the backing
file is removed.
The virDomainBlockPull API family brings this functionality to libvirt.
virDomainBlockPullAll() instructs the hypervisor to stream the entire device in
the background. Progress of this operation can be checked with the function
virDomainBlockPullInfo(). An ongoing stream can be cancelled with
virDomainBlockPullAbort(). If a more controlled IO rate is desired,
virDomainBlockPull() can be used to perform a single increment of IO.
Subsequent calls to this function will automatically stream the appropriate
next increment until the disk has been fully populated.
An event (VIR_DOMAIN_EVENT_ID_BLOCK_PULL) will be emitted when a disk has been
fully populated or if a BlockPullAll() operation was terminated due to an
error. This event is useful to avoid polling on virDomainBlockPullInfo() for
completion and could also be used by the security driver to revoke access to
the backing file when it is no longer needed.
make check: PASS
make syntax-check: PASS
make -C tests valgrind: PASS
I am testing this API with Python Unittest (see the last patch).
[PATCH 1/8] Add new API virDomainBlockPull* to headers
[PATCH 2/8] virDomainBlockPull: Implement the main entry points
[PATCH 3/8] Add virDomainBlockPull support to the remote driver
[PATCH 4/8] Implement virDomainBlockPull for the qemu driver
[PATCH 5/8] Enable the virDomainBlockPull API in virsh
[PATCH 6/8] Enable virDomainBlockPull in the python API.
[PATCH 7/8] Asynchronous event for BlockPull completion
[PATCH 8/8] test: Python Unittests for DomainBlockPull API
13 years, 10 months
[libvirt] [PATCH] sendkey: use consistent API convention
by Eric Blake
Even though rpc uses 'unsigned int' for the _val parameter that
passes the length of item<length>, the public libvirt APIs all
use 'int' and filter out lengths < 0, except for virDomainSendKey.
* include/libvirt/libvirt.h.in (virDomainSendKey): All other APIs
use int for array length.
* src/libvirt.c (virDomainSendKey): Adjust.
* src/driver.h (virDrvDomainSendKey): Likewise.
* daemon/remote_generator.pl: Likewise.
---
One approach to a question first raised here.
https://www.redhat.com/archives/libvir-list/2011-June/msg00681.html
The other approach would be to change all libvirt API to use
unsigned int for array sizes, to match rpc conventions and to
simplify code to not have to worry about negative sizes, but
that is more invasive.
daemon/remote_generator.pl | 2 +-
include/libvirt/libvirt.h.in | 2 +-
src/driver.h | 2 +-
src/libvirt.c | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl
index 351866b..afec66c 100755
--- a/daemon/remote_generator.pl
+++ b/daemon/remote_generator.pl
@@ -1007,7 +1007,7 @@ elsif ($opt_k) {
my $limit = $3;
push(@args_list, "${type_name} *$arg_name");
- push(@args_list, "unsigned int ${arg_name}len");
+ push(@args_list, "int ${arg_name}len");
push(@setters_list, "args.$arg_name.${arg_name}_val = $arg_name;");
push(@setters_list, "args.$arg_name.${arg_name}_len = ${arg_name}len;");
push(@args_check_list, { name => "\"$arg_name\"", arg => "${arg_name}len", limit => $limit });
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index ab22046..c684297 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1788,7 +1788,7 @@ int virDomainSendKey(virDomainPtr domain,
unsigned int codeset,
unsigned int holdtime,
unsigned int *keycodes,
- unsigned int nkeycodes,
+ int nkeycodes,
unsigned int flags);
/*
diff --git a/src/driver.h b/src/driver.h
index d45575a..c880222 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -568,7 +568,7 @@ typedef int
(*virDrvDomainSendKey)(virDomainPtr dom, unsigned int codeset,
unsigned int holdtime,
unsigned int *keycodes,
- unsigned int nkeycodes,
+ int nkeycodes,
unsigned int flags);
typedef char *
diff --git a/src/libvirt.c b/src/libvirt.c
index 36a90d1..b2e1d02 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -6653,7 +6653,7 @@ int virDomainSendKey(virDomainPtr domain,
unsigned int codeset,
unsigned int holdtime,
unsigned int *keycodes,
- unsigned int nkeycodes,
+ int nkeycodes,
unsigned int flags)
{
virConnectPtr conn;
@@ -6663,7 +6663,7 @@ int virDomainSendKey(virDomainPtr domain,
virResetLastError();
if (keycodes == NULL ||
- nkeycodes == 0 || nkeycodes > VIR_DOMAIN_SEND_KEY_MAX_KEYS) {
+ nkeycodes <= 0 || nkeycodes > VIR_DOMAIN_SEND_KEY_MAX_KEYS) {
virLibDomainError(VIR_ERR_OPERATION_INVALID, __FUNCTION__);
virDispatchError(NULL);
return -1;
--
1.7.4.4
13 years, 10 months
[libvirt] [PATCH] build: export correct function names
by Eric Blake
Detected by autobuild.sh, when targetting mingw.
* src/libvirt_private.syms: Fix typos.
---
Pushing under the trivial rule.
src/libvirt_private.syms | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index ab110a3..5202da3 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -274,8 +274,8 @@ virDomainGraphicsSpiceChannelModeTypeFromString;
virDomainGraphicsSpiceChannelModeTypeToString;
virDomainGraphicsSpiceChannelNameTypeFromString;
virDomainGraphicsSpiceChannelNameTypeToString;
-virDomainGraphicsSpiceClipboardCopypasteFromString;
-virDomainGraphicsSpiceClipboardCopypasteToString;
+virDomainGraphicsSpiceClipboardCopypasteTypeFromString;
+virDomainGraphicsSpiceClipboardCopypasteTypeToString;
virDomainGraphicsSpiceImageCompressionTypeFromString;
virDomainGraphicsSpiceImageCompressionTypeToString;
virDomainGraphicsSpiceJpegCompressionTypeFromString;
--
1.7.4.4
13 years, 10 months
[libvirt] [PATCH] build: avoid compiler warning on non-Linux
by Eric Blake
Detected by autobuild.sh when cross-building for mingw.
* src/nodeinfo.c (nodeGetCPUStats, nodeGetMemoryStats): Mark
parameters as potentially unused.
---
Pushing under the build-breaker rule.
src/nodeinfo.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index cb2f805..647cb1e 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -636,9 +636,9 @@ int nodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED, virNodeInfoPtr nodeinfo) {
}
int nodeGetCPUStats(virConnectPtr conn ATTRIBUTE_UNUSED,
- int cpuNum,
- virCPUStatsPtr params,
- int *nparams,
+ int cpuNum ATTRIBUTE_UNUSED,
+ virCPUStatsPtr params ATTRIBUTE_UNUSED,
+ int *nparams ATTRIBUTE_UNUSED,
unsigned int flags)
{
virCheckFlags(0, -1);
@@ -665,9 +665,9 @@ int nodeGetCPUStats(virConnectPtr conn ATTRIBUTE_UNUSED,
}
int nodeGetMemoryStats(virConnectPtr conn ATTRIBUTE_UNUSED,
- int cellNum,
- virMemoryStatsPtr params,
- int *nparams,
+ int cellNum ATTRIBUTE_UNUSED,
+ virMemoryStatsPtr params ATTRIBUTE_UNUSED,
+ int *nparams ATTRIBUTE_UNUSED,
unsigned int flags)
{
virCheckFlags(0, -1);
--
1.7.4.4
13 years, 10 months
[libvirt] [PATCH] remote generator: Handle struct returning functions better (part 2)
by Matthias Bolte
Commit 64000eabedf2 is part 1, that only covered the daemon side by
accident. Part 2 covers the client side too.
---
daemon/remote_generator.pl | 17 +++++------------
1 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl
index 351866b..bcf5fd4 100755
--- a/daemon/remote_generator.pl
+++ b/daemon/remote_generator.pl
@@ -1225,21 +1225,14 @@ elsif ($opt_k) {
# select struct type for multi-return-value functions
if ($multi_ret) {
- my $last_arg;
- my $struct_name = $call->{ProcName};
- $struct_name =~ s/Get//;
-
- if ($call->{ProcName} eq "DomainGetBlockInfo") {
- # SPECIAL: virDomainGetBlockInfo has flags parameter after
- # the struct parameter in its signature
- $last_arg = pop(@args_list);
+ if (!(defined $call->{ret_offset})) {
+ die "multi-return-value without insert@<offset> annotation: $call->{ret}";
}
- push(@args_list, "vir${struct_name}Ptr result");
+ my $struct_name = $call->{ProcName};
+ $struct_name =~ s/Get//;
- if (defined $last_arg) {
- push(@args_list, $last_arg);
- }
+ splice(@args_list, $call->{ret_offset}, 0, ("vir${struct_name}Ptr result"));
}
if ($call->{streamflag} ne "none") {
--
1.7.0.4
13 years, 10 months
[libvirt] [PATCH] Fix apibuild.py warnings about missing comment headers
by Matthias Bolte
Also improve wording of some comments.
---
include/libvirt/libvirt.h.in | 36 ++++++++++++++++++++++--------------
1 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 8ceafe5..cf1a682 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -318,33 +318,41 @@ struct _virNodeInfo {
/**
* VIR_CPU_STATS_KERNEL:
*
- * Macro for the cumulative CPU time which spends by kernel,
- * when the node booting up.(in nanoseconds).
+ * Macro for the cumulative CPU time which was spend by kernel,
+ * since the node booting up (in nanoseconds).
*/
#define VIR_CPU_STATS_KERNEL "kernel"
/**
- * The cumulative CPU time which spends by user processes,
- * when the node booting up.(in nanoseconds).
+ * VIR_CPU_STATS_USER:
+ *
+ * The cumulative CPU time which was spend by user processes,
+ * since the node booting up (in nanoseconds).
*/
#define VIR_CPU_STATS_USER "user"
/**
+ * VIR_CPU_STATS_IDLE:
+ *
* The cumulative idle CPU time,
- * when the node booting up.(in nanoseconds).
+ * since the node booting up (in nanoseconds).
*/
#define VIR_CPU_STATS_IDLE "idle"
/**
+ * VIR_CPU_STATS_IOWAIT:
+ *
* The cumulative I/O wait CPU time,
- * when the node booting up.(in nanoseconds).
+ * since the node booting up (in nanoseconds).
*/
#define VIR_CPU_STATS_IOWAIT "iowait"
/**
- * The CPU utilization.
- * The usage value is in percent and 100% represents all CPUs on
- * the server.
+ * VIR_CPU_STATS_UTILIZATION:
+ *
+ * The CPU utilization of a node.
+ * The usage value is in percent and 100% represents all CPUs of
+ * the node.
*/
#define VIR_CPU_STATS_UTILIZATION "utilization"
@@ -352,7 +360,7 @@ struct _virNodeInfo {
* virCPUStats:
*
* a virNodeCPUStats is a structure filled by virNodeGetCPUStats()
- * and providing the information for the cpu stats of the node.
+ * providing information about the CPU stats of the node.
*/
typedef struct _virCPUStats virCPUStats;
@@ -388,7 +396,7 @@ struct _virCPUStats {
* VIR_MEMORY_STATS_FREE:
*
* Macro for the free memory of specified cell:
- * On linux, it includes buffer and cached memory, in case of
+ * On Linux, it includes buffer and cached memory, in case of
* VIR_MEMORY_STATS_ALL_CELLS.
*/
@@ -397,7 +405,7 @@ struct _virCPUStats {
/**
* VIR_MEMORY_STATS_BUFFERS:
*
- * Macro for the buffer memory: On linux, it only returns in case of
+ * Macro for the buffer memory: On Linux, it is only returned in case of
* VIR_MEMORY_STATS_ALL_CELLS.
*/
@@ -406,7 +414,7 @@ struct _virCPUStats {
/**
* VIR_MEMORY_STATS_CACHED:
*
- * Macro for the cached memory: On linux, it only returns in case of
+ * Macro for the cached memory: On Linux, it is only returned in case of
* VIR_MEMORY_STATS_ALL_CELLS.
*/
@@ -416,7 +424,7 @@ struct _virCPUStats {
* virMemoryStats:
*
* a virMemoryStats is a structure filled by virNodeGetMemoryStats()
- * and providing the information of the memory of the Node.
+ * providing information about the memory of the node.
*/
typedef struct _virMemoryStats virMemoryStats;
--
1.7.0.4
13 years, 10 months
[libvirt] [PATCH] remote generator: Handle struct returning functions better
by Matthias Bolte
The position of the struct parameter in the function signature
differs. Instead of hardcoding the handling for this add an annotation
to the .x file to define the position.
---
daemon/remote_generator.pl | 42 ++++++++++++++++++++++++------------------
src/remote/remote_protocol.x | 23 ++++++++++++++---------
2 files changed, 38 insertions(+), 27 deletions(-)
diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl
index ce35ebe..351866b 100755
--- a/daemon/remote_generator.pl
+++ b/daemon/remote_generator.pl
@@ -95,8 +95,9 @@ while (<PROTOCOL>) {
$collect_args_members = 1;
$collect_ret_members = 0;
$last_name = $name;
- } elsif (/^struct ${structprefix}_(.*)_ret/) {
+ } elsif (/^struct ${structprefix}_(.*)_ret\s+{(.*)$/) {
$name = $1;
+ $flags = $2;
$ProcName = name_to_ProcName ($name);
if (exists $calls{$name}) {
@@ -112,6 +113,14 @@ while (<PROTOCOL>) {
}
}
+ if ($flags ne "" and ($opt_b or $opt_k)) {
+ if (!($flags =~ m/^\s*\/\*\s*insert@(\d+)\s*\*\/\s*$/)) {
+ die "invalid generator flags for $calls{$name}->{ret}";
+ }
+
+ $calls{$name}->{ret_offset} = int($1);
+ }
+
$collect_args_members = 0;
$collect_ret_members = 1;
$last_name = $name;
@@ -668,29 +677,26 @@ elsif ($opt_b) {
# select struct type for multi-return-value functions
if ($multi_ret) {
- if (! @args_list) {
+ if (!(defined $call->{ret_offset})) {
+ die "multi-return-value without insert@<offset> annotation: $call->{ret}";
+ }
+
+ if (!@args_list) {
push(@args_list, "conn");
}
my $struct_name = $call->{ProcName};
$struct_name =~ s/Get//;
- if ($call->{ProcName} eq "DomainGetBlockInfo") {
- # SPECIAL: virDomainGetBlockInfo has flags parameter after
- # the struct parameter in its signature
- my $flags = pop(@args_list);
- push(@args_list, "&tmp");
- push(@args_list, $flags);
- } elsif ($call->{ProcName} eq "DomainBlockStats" ||
- $call->{ProcName} eq "DomainInterfaceStats") {
+ splice(@args_list, $call->{ret_offset}, 0, ("&tmp"));
+
+ if ($call->{ProcName} eq "DomainBlockStats" ||
+ $call->{ProcName} eq "DomainInterfaceStats") {
# SPECIAL: virDomainBlockStats and virDomainInterfaceStats
# have a 'Struct' suffix on the actual struct name
# and take the struct size as additional argument
$struct_name .= "Struct";
- push(@args_list, "&tmp");
- push(@args_list, "sizeof tmp");
- } else {
- push(@args_list, "&tmp");
+ splice(@args_list, $call->{ret_offset} + 1, 0, ("sizeof tmp"));
}
push(@vars_list, "vir$struct_name tmp");
@@ -1012,14 +1018,14 @@ elsif ($opt_k) {
" xdr_free((xdrproc_t)xdr_$call->{args}, (char *)&args);\n" .
" goto done;\n" .
" }");
- } elsif ($args_member =~ m/^(unsigned )?int (\S+);\s*\/\*\s*call-by-reference\s*\*\//) {
- my $type_name = $1; $type_name .= "int *";
+ } elsif ($args_member =~ m/^((?:unsigned )?int) (\S+);\s*\/\*\s*call-by-reference\s*\*\//) {
+ my $type_name = "$1 *";
my $arg_name = $2;
push(@args_list, "$type_name $arg_name");
push(@setters_list, "args.$arg_name = *$arg_name;");
- } elsif ($args_member =~ m/^(unsigned )?int (\S+);/) {
- my $type_name = $1; $type_name .= "int";
+ } elsif ($args_member =~ m/^((?:unsigned )?int) (\S+);/) {
+ my $type_name = $1;
my $arg_name = $2;
push(@args_list, "$type_name $arg_name");
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 0dd8b09..2b9784b 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -352,7 +352,12 @@ struct remote_node_get_memory_stats {
*
* 'remote_CALL_ret' members that are filled via call-by-reference must be
* annotated with a insert@<offset> comment to indicate the offset in the
- * parameter list of the function to be called. */
+ * parameter list of the function to be called.
+ *
+ * If the 'remote_CALL_ret' maps to a struct in the public API then it is
+ * also filled via call-by-reference and must be annotated with a
+ * insert@<offset> comment to indicate the offset in the parameter list of
+ * the function to be called. */
struct remote_open_args {
/* NB. "name" might be NULL although in practice you can't
@@ -409,7 +414,7 @@ struct remote_get_max_vcpus_ret {
int max_vcpus;
};
-struct remote_node_get_info_ret {
+struct remote_node_get_info_ret { /* insert@1 */
char model[32];
unsigned hyper memory;
int cpus;
@@ -537,7 +542,7 @@ struct remote_domain_block_stats_args {
remote_nonnull_string path;
};
-struct remote_domain_block_stats_ret {
+struct remote_domain_block_stats_ret { /* insert@2 */
hyper rd_req;
hyper rd_bytes;
hyper wr_req;
@@ -550,7 +555,7 @@ struct remote_domain_interface_stats_args {
remote_nonnull_string path;
};
-struct remote_domain_interface_stats_ret {
+struct remote_domain_interface_stats_ret { /* insert@2 */
hyper rx_bytes;
hyper rx_packets;
hyper rx_errs;
@@ -605,7 +610,7 @@ struct remote_domain_get_block_info_args {
unsigned int flags;
};
-struct remote_domain_get_block_info_ret {
+struct remote_domain_get_block_info_ret { /* insert@2 */
unsigned hyper allocation;
unsigned hyper capacity;
unsigned hyper physical;
@@ -713,7 +718,7 @@ struct remote_domain_get_info_args {
remote_nonnull_domain dom;
};
-struct remote_domain_get_info_ret {
+struct remote_domain_get_info_ret { /* insert@1 */
unsigned char state;
unsigned hyper maxMem;
unsigned hyper memory;
@@ -1400,7 +1405,7 @@ struct remote_storage_pool_get_info_args {
remote_nonnull_storage_pool pool;
};
-struct remote_storage_pool_get_info_ret {
+struct remote_storage_pool_get_info_ret { /* insert@1 */
unsigned char state;
unsigned hyper capacity;
unsigned hyper allocation;
@@ -1510,7 +1515,7 @@ struct remote_storage_vol_get_info_args {
remote_nonnull_storage_vol vol;
};
-struct remote_storage_vol_get_info_ret {
+struct remote_storage_vol_get_info_ret { /* insert@1 */
char type;
unsigned hyper capacity;
unsigned hyper allocation;
@@ -1827,7 +1832,7 @@ struct remote_domain_get_job_info_args {
remote_nonnull_domain dom;
};
-struct remote_domain_get_job_info_ret {
+struct remote_domain_get_job_info_ret { /* insert@1 */
int type;
unsigned hyper timeElapsed;
--
1.7.0.4
13 years, 10 months
[libvirt] [PATCH] support for Xen HVM Viridian (Hyper-V) enlightenment interface
by Daniel Gollub
Introduce libvirt support for Xen HVM Viridian (Hyper-V) enlightenment
interface guest feature.
---
src/conf/domain_conf.c | 3 ++-
src/conf/domain_conf.h | 1 +
src/xen/xen_hypervisor.c | 11 +++++++++++
src/xenapi/xenapi_driver.c | 2 ++
src/xenapi/xenapi_utils.c | 2 ++
src/xenxs/xen_sxpr.c | 4 ++++
src/xenxs/xen_xm.c | 12 +++++++++++-
7 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0d9fef4..a90f676 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -84,7 +84,8 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST,
"acpi",
"apic",
"pae",
- "hap")
+ "hap",
+ "viridian")
VIR_ENUM_IMPL(virDomainLifecycle, VIR_DOMAIN_LIFECYCLE_LAST,
"destroy",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 41c8136..e591268 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -890,6 +890,7 @@ enum virDomainFeature {
VIR_DOMAIN_FEATURE_APIC,
VIR_DOMAIN_FEATURE_PAE,
VIR_DOMAIN_FEATURE_HAP,
+ VIR_DOMAIN_FEATURE_VIRIDIAN,
VIR_DOMAIN_FEATURE_LAST
};
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 21e6645..ff9c8cb 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -2401,7 +2401,18 @@ xenHypervisorBuildCapabilities(virConnectPtr conn,
0,
1) == NULL)
goto no_memory;
+
+ /* Xen 3.4.x and beyond supports the Viridian (Hyper-V)
+ * enlightenment interface. Default is off.
+ */
+ if ((hv_major == 3 && hv_minor >= 4) || (hv_major > 3))
+ if (virCapabilitiesAddGuestFeature(guest,
+ "viridian",
+ 0,
+ 1) == NULL)
+ goto no_memory;
}
+
}
caps->defaultConsoleTargetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 6f64208..58e762f 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -1414,6 +1414,8 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, int flags ATTRIBUTE_UNUSED)
defPtr->features = defPtr->features | (1<<VIR_DOMAIN_FEATURE_PAE);
else if (STREQ(result->contents[i].key, "hap"))
defPtr->features = defPtr->features | (1<<VIR_DOMAIN_FEATURE_HAP);
+ else if (STREQ(result->contents[i].key, "viridian"))
+ defPtr->features = defPtr->features | (1<<VIR_DOMAIN_FEATURE_VIRIDIAN);
}
}
xen_string_string_map_free(result);
diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index 9362cf1..342ae5b 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -536,6 +536,8 @@ createVMRecordFromXml (virConnectPtr conn, virDomainDefPtr def,
allocStringMap(&strings, (char *)"pae", (char *)"true");
if (def->features & (1 << VIR_DOMAIN_FEATURE_HAP))
allocStringMap(&strings, (char *)"hap", (char *)"true");
+ if (def->features & (1 << VIR_DOMAIN_FEATURE_VIRIDIAN))
+ allocStringMap(&strings, (char *)"viridian", (char *)"true");
}
if (strings != NULL)
(*record)->platform = strings;
diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c
index 59d585d..b5877bb 100644
--- a/src/xenxs/xen_sxpr.c
+++ b/src/xenxs/xen_sxpr.c
@@ -1171,6 +1171,8 @@ xenParseSxpr(const struct sexpr *root,
def->features |= (1 << VIR_DOMAIN_FEATURE_PAE);
if (sexpr_int(root, "domain/image/hvm/hap"))
def->features |= (1 << VIR_DOMAIN_FEATURE_HAP);
+ if (sexpr_int(root, "domain/image/hvm/viridian"))
+ def->features |= (1 << VIR_DOMAIN_FEATURE_VIRIDIAN);
/* Old XenD only allows localtime here for HVM */
if (sexpr_int(root, "domain/image/hvm/localtime"))
@@ -2166,6 +2168,8 @@ xenFormatSxpr(virConnectPtr conn,
virBufferAddLit(&buf, "(pae 1)");
if (def->features & (1 << VIR_DOMAIN_FEATURE_HAP))
virBufferAddLit(&buf, "(hap 1)");
+ if (def->features & (1 << VIR_DOMAIN_FEATURE_VIRIDIAN))
+ virBufferAddLit(&buf, "(viridian 1)");
virBufferAddLit(&buf, "(usb 1)");
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index accf5f4..c9440fa 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -369,6 +369,10 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
goto cleanup;
else if (val)
def->features |= (1 << VIR_DOMAIN_FEATURE_HAP);
+ if (xenXMConfigGetBool(conf, "viridian", &val, 0) < 0)
+ goto cleanup;
+ else if (val)
+ def->features |= (1 << VIR_DOMAIN_FEATURE_VIRIDIAN);
if (xenXMConfigGetBool(conf, "hpet", &val, -1) < 0)
goto cleanup;
@@ -1507,12 +1511,18 @@ virConfPtr xenFormatXM(virConnectPtr conn,
(1 << VIR_DOMAIN_FEATURE_APIC)) ? 1 : 0) < 0)
goto no_memory;
- if (xendConfigVersion >= 3)
+ if (xendConfigVersion >= 3) {
if (xenXMConfigSetInt(conf, "hap",
(def->features &
(1 << VIR_DOMAIN_FEATURE_HAP)) ? 1 : 0) < 0)
goto no_memory;
+ if (xenXMConfigSetInt(conf, "viridian",
+ (def->features &
+ (1 << VIR_DOMAIN_FEATURE_VIRIDIAN)) ? 1 : 0) < 0)
+ goto no_memory;
+ }
+
if (def->clock.offset == VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME) {
if (def->clock.data.timezone) {
XENXS_ERROR(VIR_ERR_CONFIG_UNSUPPORTED,
--
1.7.1
--
Daniel Gollub
Linux Consultant & Developer
Tel.: +49-160 47 73 970
Mail: gollub(a)b1-systems.de
B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
13 years, 10 months
[libvirt] [PATCH] qemu: domain I/O asynchronous handling
by Michal Privoznik
For virtio disks and interfaces, qemu allows users to enable or disable
ioeventfd feature. This means, qemu can execute domain code, while
another thread waits for I/O event. Basically, in some cases it is win,
in some loss. This feature is available via 'asyncio' attribute in disk
and interface <driver> element. It accepts 'on' and 'off'. Leaving this
attribute out defaults to hypervisor decision.
---
this is rework as suggested:
https://www.redhat.com/archives/libvir-list/2011-May/msg01269.html
docs/formatdomain.html.in | 34 ++++++++++++-
docs/schemas/domain.rng | 14 +++++
src/conf/domain_conf.c | 49 ++++++++++++++++++-
src/conf/domain_conf.h | 11 ++++
src/libvirt_private.syms | 2 +
src/qemu/qemu_capabilities.c | 3 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 23 +++++++++
tests/qemuhelptest.c | 3 +-
.../qemuxml2argv-disk-asyncio.args | 11 ++++
.../qemuxml2argvdata/qemuxml2argv-disk-asyncio.xml | 51 ++++++++++++++++++++
tests/qemuxml2argvtest.c | 3 +
12 files changed, 201 insertions(+), 4 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-asyncio.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-asyncio.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 98fb2b4..8d23740 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -767,7 +767,7 @@
</disk>
...
<disk type='network'>
- <driver name="qemu" type="raw" io="threads"/>
+ <driver name="qemu" type="raw" io="threads" asyncio="on"/>
<source protocol="sheepdog" name="image_name">
<host name="hostname" port="7000"/>
</source>
@@ -851,6 +851,20 @@
policies on I/O; qemu guests support "threads" and
"native". <span class="since">Since 0.8.8</span>
</li>
+ <li>
+ The optional <code>asyncio</code> attribute allows users to
+ set <a href='https://patchwork.kernel.org/patch/43390/'>
+ domain I/O asynchronous handling</a> for disk device.
+ The default is left to the discretion of the hypervisor.
+ Accepted values are "on" and "off". Enabling this allows
+ qemu to execute VM while a separate thread handles I/O.
+ Typically guests experiencing high system CPU utilization
+ during I/O will benefit from this. On the other hand,
+ on overloaded host it could increase guest I/O latency.
+ <span class="since">Since 0.9.3 (QEMU and KVM only)</span>
+ <b>In general you should leave this option alone, unless you
+ are very certain you know what you are doing.</b>
+ </li>
</ul>
</dd>
<dt><code>boot</code></dt>
@@ -1631,7 +1645,7 @@ qemu-kvm -net nic,model=? /dev/null
<source network='default'/>
<target dev='vnet1'/>
<model type='virtio'/>
- <b><driver name='vhost' txmode='iothread'/></b>
+ <b><driver name='vhost' txmode='iothread' asyncio='on'/></b>
</interface>
</devices>
...</pre>
@@ -1682,6 +1696,22 @@ qemu-kvm -net nic,model=? /dev/null
<b>In general you should leave this option alone, unless you
are very certain you know what you are doing.</b>
</dd>
+ <dt><code>asyncio</code></dt>
+ <dd>
+ This optional attribute allows users to set
+ <a href='https://patchwork.kernel.org/patch/43390/'>
+ domain I/O asynchronous handling</a> for interface device.
+ The default is left to the discretion of the hypervisor.
+ Accepted values are "on" and "off". Enabling this allows
+ qemu to execute VM while a separate thread handles I/O.
+ Typically guests experiencing high system CPU utilization
+ during I/O will benefit from this. On the other hand,
+ on overloaded host it could increase guest I/O latency.
+ <span class="since">Since 0.9.3 (QEMU and KVM only)</span><br/><br/>
+
+ <b>In general you should leave this option alone, unless you
+ are very certain you know what you are doing.</b>
+ </dd>
</dl>
<h5><a name="elementsNICSTargetOverride">Overriding the target element</a></h5>
diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 0be0371..08b92ed 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -758,6 +758,9 @@
<optional>
<ref name="driverIO"/>
</optional>
+ <optional>
+ <ref name="asyncIO"/>
+ </optional>
<empty/>
</element>
</define>
@@ -797,6 +800,14 @@
</choice>
</attribute>
</define>
+ <define name="asyncIO">
+ <attribute name="asyncio">
+ <choice>
+ <value>on</value>
+ <value>off</value>
+ </choice>
+ </attribute>
+ </define>
<define name="controller">
<element name="controller">
<choice>
@@ -1097,6 +1108,9 @@
</choice>
</attribute>
</optional>
+ <optional>
+ <ref name="asyncIO"/>
+ </optional>
<empty/>
</element>
</optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 65d4f89..2b81f2b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -163,6 +163,11 @@ VIR_ENUM_IMPL(virDomainDiskIo, VIR_DOMAIN_DISK_IO_LAST,
"native",
"threads")
+VIR_ENUM_IMPL(virDomainAsyncIo, VIR_DOMAIN_ASYNC_IO_LAST,
+ "default",
+ "on",
+ "off")
+
VIR_ENUM_IMPL(virDomainController, VIR_DOMAIN_CONTROLLER_TYPE_LAST,
"ide",
"fdc",
@@ -2001,6 +2006,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
char *cachetag = NULL;
char *error_policy = NULL;
char *iotag = NULL;
+ char *asyncio = NULL;
char *devaddr = NULL;
virStorageEncryptionPtr encryption = NULL;
char *serial = NULL;
@@ -2116,6 +2122,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
cachetag = virXMLPropString(cur, "cache");
error_policy = virXMLPropString(cur, "error_policy");
iotag = virXMLPropString(cur, "io");
+ asyncio = virXMLPropString(cur, "asyncio");
} else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) {
def->readonly = 1;
} else if (xmlStrEqual(cur->name, BAD_CAST "shareable")) {
@@ -2252,6 +2259,24 @@ virDomainDiskDefParseXML(virCapsPtr caps,
}
}
+ if (asyncio) {
+ if (def->bus != VIR_DOMAIN_DISK_BUS_VIRTIO) {
+ virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("disk asyncio mode supported "
+ "only for virtio bus"));
+ goto error;
+ }
+
+ int i;
+ if ((i = virDomainAsyncIoTypeFromString(asyncio)) <= 0) {
+ virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown disk asyncio mode '%s'"),
+ asyncio);
+ goto error;
+ }
+ def->asyncio=i;
+ }
+
if (devaddr) {
if (virDomainParseLegacyDeviceAddress(devaddr,
&def->info.addr.pci) < 0) {
@@ -2314,6 +2339,7 @@ cleanup:
VIR_FREE(cachetag);
VIR_FREE(error_policy);
VIR_FREE(iotag);
+ VIR_FREE(asyncio);
VIR_FREE(devaddr);
VIR_FREE(serial);
virStorageEncryptionFree(encryption);
@@ -2701,6 +2727,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
char *model = NULL;
char *backend = NULL;
char *txmode = NULL;
+ char *asyncio = NULL;
char *filter = NULL;
char *internal = NULL;
char *devaddr = NULL;
@@ -2790,6 +2817,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
} else if (xmlStrEqual (cur->name, BAD_CAST "driver")) {
backend = virXMLPropString(cur, "name");
txmode = virXMLPropString(cur, "txmode");
+ asyncio = virXMLPropString(cur, "asyncio");
} else if (xmlStrEqual (cur->name, BAD_CAST "filterref")) {
filter = virXMLPropString(cur, "filter");
VIR_FREE(filterparams);
@@ -3006,6 +3034,16 @@ virDomainNetDefParseXML(virCapsPtr caps,
}
def->driver.virtio.txmode = m;
}
+ if (asyncio) {
+ int i;
+ if ((i = virDomainAsyncIoTypeFromString(asyncio)) <= 0) {
+ virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown interface asyncio mode '%s'"),
+ asyncio);
+ goto error;
+ }
+ def->driver.virtio.asyncio = i;
+ }
}
if (filter != NULL) {
@@ -3045,6 +3083,7 @@ cleanup:
VIR_FREE(model);
VIR_FREE(backend);
VIR_FREE(txmode);
+ VIR_FREE(asyncio);
VIR_FREE(filter);
VIR_FREE(type);
VIR_FREE(internal);
@@ -8175,6 +8214,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
const char *cachemode = virDomainDiskCacheTypeToString(def->cachemode);
const char *error_policy = virDomainDiskErrorPolicyTypeToString(def->error_policy);
const char *iomode = virDomainDiskIoTypeToString(def->iomode);
+ const char *asyncio = virDomainAsyncIoTypeToString(def->asyncio);
if (!type) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
@@ -8206,7 +8246,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
" <disk type='%s' device='%s'>\n",
type, device);
- if (def->driverName || def->driverType || def->cachemode) {
+ if (def->driverName || def->driverType || def->cachemode ||
+ def->asyncio) {
virBufferAsprintf(buf, " <driver");
if (def->driverName)
virBufferAsprintf(buf, " name='%s'", def->driverName);
@@ -8218,6 +8259,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, " error_policy='%s'", error_policy);
if (def->iomode)
virBufferAsprintf(buf, " io='%s'", iomode);
+ if (def->asyncio)
+ virBufferAsprintf(buf, " asyncio='%s'", asyncio);
virBufferAsprintf(buf, "/>\n");
}
@@ -8508,6 +8551,10 @@ virDomainNetDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, " txmode='%s'",
virDomainNetVirtioTxModeTypeToString(def->driver.virtio.txmode));
}
+ if (def->driver.virtio.asyncio) {
+ virBufferAsprintf(buf, " asyncio='%s'",
+ virDomainAsyncIoTypeToString(def->driver.virtio.asyncio));
+ }
virBufferAddLit(buf, "/>\n");
}
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 41c8136..01a98c9 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -206,6 +206,14 @@ enum virDomainDiskIo {
VIR_DOMAIN_DISK_IO_LAST
};
+enum virDomainAsyncIo {
+ VIR_DOMAIN_ASYNC_IO_DEFAULT = 0,
+ VIR_DOMAIN_ASYNC_IO_ON,
+ VIR_DOMAIN_ASYNC_IO_OFF,
+
+ VIR_DOMAIN_ASYNC_IO_LAST
+};
+
/* Stores the virtual disk configuration */
typedef struct _virDomainDiskDef virDomainDiskDef;
typedef virDomainDiskDef *virDomainDiskDefPtr;
@@ -225,6 +233,7 @@ struct _virDomainDiskDef {
int error_policy;
int bootIndex;
int iomode;
+ int asyncio;
unsigned int readonly : 1;
unsigned int shared : 1;
virDomainDeviceInfo info;
@@ -361,6 +370,7 @@ struct _virDomainNetDef {
struct {
enum virDomainNetBackendType name; /* which driver backend to use */
enum virDomainNetVirtioTxModeType txmode;
+ enum virDomainAsyncIo asyncio;
} virtio;
} driver;
union {
@@ -1521,6 +1531,7 @@ VIR_ENUM_DECL(virDomainDiskCache)
VIR_ENUM_DECL(virDomainDiskErrorPolicy)
VIR_ENUM_DECL(virDomainDiskProtocol)
VIR_ENUM_DECL(virDomainDiskIo)
+VIR_ENUM_DECL(virDomainAsyncIo)
VIR_ENUM_DECL(virDomainController)
VIR_ENUM_DECL(virDomainControllerModel)
VIR_ENUM_DECL(virDomainFS)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 737cd31..f3a44f6 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -205,6 +205,8 @@ dnsmasqSave;
virDiskNameToBusDeviceIndex;
virDiskNameToIndex;
virDomainAssignDef;
+virDomainAsyncIoTypeFromString;
+virDomainAsyncIoTypeToString;
virDomainChrConsoleTargetTypeFromString;
virDomainChrConsoleTargetTypeToString;
virDomainChrDefForeach;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 28c89b5..ad62a07 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -121,6 +121,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
"device-qxl-vga",
"pci-multifunction", /* 60 */
+ "virtio-blk-pci.ioeventfd",
);
struct qemu_feature_flags {
@@ -1207,6 +1208,8 @@ qemuCapsParseDeviceStr(const char *str, virBitmapPtr flags)
qemuCapsSet(flags, QEMU_CAPS_VIRTIO_TX_ALG);
if (strstr(str, "name \"qxl-vga\""))
qemuCapsSet(flags, QEMU_CAPS_DEVICE_QXL_VGA);
+ if (strstr(str, "virtio-blk-pci.ioeventfd"))
+ qemuCapsSet(flags, QEMU_CAPS_VIRTIO_IOEVENTFD);
return 0;
}
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index e6d2fa3..0b9c8be 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -96,6 +96,7 @@ enum qemuCapsFlags {
QEMU_CAPS_VIRTIO_TX_ALG = 58, /* -device virtio-net-pci,tx=string */
QEMU_CAPS_DEVICE_QXL_VGA = 59, /* Is the primary and vga campatible qxl device named qxl-vga? */
QEMU_CAPS_PCI_MULTIFUNCTION = 60, /* -device multifunction=on|off */
+ QEMU_CAPS_VIRTIO_IOEVENTFD = 61, /* IOeventFD feature: virtio-{net|blk}-pci.ioeventfd=on/off */
QEMU_CAPS_LAST, /* this must always be the last item */
};
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index cb81354..8273e7e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1287,6 +1287,26 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
return 0;
}
+static int
+qemuBuildAsyncIoStr(virBufferPtr buf,
+ enum virDomainAsyncIo use,
+ virBitmapPtr qemuCaps)
+{
+ if (qemuCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_IOEVENTFD)) {
+ switch (use) {
+ case VIR_DOMAIN_ASYNC_IO_ON:
+ case VIR_DOMAIN_ASYNC_IO_OFF:
+ virBufferAsprintf(buf, ",ioeventfd=%s",
+ virDomainAsyncIoTypeToString(use));
+ break;
+ default:
+ /* In other cases (_DEFAULT, _LAST) we don't
+ * want to add anything */
+ break;
+ }
+ }
+ return 0;
+}
#define QEMU_SERIAL_PARAM_ACCEPTED_CHARS \
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
@@ -1552,6 +1572,7 @@ qemuBuildDriveDevStr(virDomainDiskDefPtr disk,
break;
case VIR_DOMAIN_DISK_BUS_VIRTIO:
virBufferAddLit(&opt, "virtio-blk-pci");
+ qemuBuildAsyncIoStr(&opt, disk->asyncio, qemuCaps);
qemuBuildDeviceAddressStr(&opt, &disk->info, qemuCaps);
break;
case VIR_DOMAIN_DISK_BUS_USB:
@@ -1774,6 +1795,8 @@ qemuBuildNicDevStr(virDomainNetDefPtr net,
goto error;
}
}
+ if (usingVirtio)
+ qemuBuildAsyncIoStr(&buf, net->driver.virtio.asyncio, qemuCaps);
if (vlan == -1)
virBufferAsprintf(&buf, ",netdev=host%s", net->info.alias);
else
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index 327a0c7..119e771 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -475,7 +475,8 @@ mymain(void)
QEMU_CAPS_CCID_PASSTHRU,
QEMU_CAPS_CHARDEV_SPICEVMC,
QEMU_CAPS_DEVICE_QXL_VGA,
- QEMU_CAPS_VIRTIO_TX_ALG);
+ QEMU_CAPS_VIRTIO_TX_ALG,
+ QEMU_CAPS_VIRTIO_IOEVENTFD);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-asyncio.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-asyncio.args
new file mode 100644
index 0000000..c512f15
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-asyncio.args
@@ -0,0 +1,11 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S -M pc-0.13 -m 1024 -smp 1 -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi \
+-boot dc -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x6 \
+-drive file=/var/lib/libvirt/images/f14.img,if=none,id=drive-virtio-disk0 \
+-device virtio-blk-pci,ioeventfd=on,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0 \
+-drive file=/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso,if=none,media=cdrom,id=drive-ide0-1-0 \
+-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \
+-device virtio-net-pci,tx=bh,ioeventfd=off,vlan=0,id=net0,mac=52:54:00:e5:48:58,bus=pci.0,addr=0x3 \
+-net user,vlan=0,name=hostnet0 -serial pty -usb -vnc 127.0.0.1:-809 -std-vga \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-asyncio.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-asyncio.xml
new file mode 100644
index 0000000..5a16bd1
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-asyncio.xml
@@ -0,0 +1,51 @@
+<domain type='qemu'>
+ <name>test</name>
+ <memory>1048576</memory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc-0.13'>hvm</type>
+ <boot dev='cdrom'/>
+ <boot dev='hd'/>
+ <bootmenu enable='yes'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='qcow2' asyncio='on'/>
+ <source file='/var/lib/libvirt/images/f14.img'/>
+ <target dev='vda' bus='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source file='/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1' unit='0'/>
+ </disk>
+ <interface type='user'>
+ <mac address='52:54:00:e5:48:58'/>
+ <model type='virtio'/>
+ <driver name='vhost' txmode='iothread' asyncio='off'/>
+ </interface>
+ <controller type='virtio-serial' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
+ </controller>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <console type='pty'>
+ <target type='serial' port='0'/>
+ </console>
+ <graphics type='vnc' port='5091' autoport='no' listen='127.0.0.1'/>
+ <video>
+ <model type='vga' vram='9216' heads='1'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </video>
+ </devices>
+</domain>
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index b8fd468..489025f 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -333,6 +333,9 @@ mymain(void)
DO_TEST("disk-aio", false,
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_AIO,
QEMU_CAPS_DRIVE_CACHE_V2, QEMU_CAPS_DRIVE_FORMAT);
+ DO_TEST("disk-asyncio", false,
+ QEMU_CAPS_DRIVE, QEMU_CAPS_VIRTIO_IOEVENTFD,
+ QEMU_CAPS_VIRTIO_TX_ALG, QEMU_CAPS_DEVICE);
DO_TEST("graphics-vnc", false, NONE);
DO_TEST("graphics-vnc-socket", false, NONE);
--
1.7.5.rc3
13 years, 10 months