[libvirt] [libvirt-python][PATCH] Implement new virNodeAllocPages API
by Michal Privoznik
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
generator.py | 1 +
libvirt-override-api.xml | 9 ++++++
libvirt-override.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 81 insertions(+)
diff --git a/generator.py b/generator.py
index 8ee046a..e8e29b9 100755
--- a/generator.py
+++ b/generator.py
@@ -465,6 +465,7 @@ skip_impl = (
'virNodeGetFreePages',
'virNetworkGetDHCPLeases',
'virDomainBlockCopy',
+ 'virNodeAllocPages',
)
lxc_skip_impl = (
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index 51d8273..4fe3c4d 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -649,5 +649,14 @@
<arg name='flags' type='unsigned int' info='bitwise-OR of virDomainBlockCopyFlags'/>
<return type='int' info='0 if the operation has started, -1 on failure'/>
</function>
+ <function name="virNodeAllocPages" file='python'>
+ <info>Allocate or free some pages in the huge pages pool</info>
+ <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
+ <arg name='pages' type='char *' info='dictionary of desired page sizes, key is page size, value is page count'/>
+ <arg name='startCell' type='int' info='optional first cell in the list'/>
+ <arg name='cellCount' type='int' info='optional number of cell in the list'/>
+ <arg name='flags' type='unsigned int' info='an OR'ed set of virNodeAllocPagesFlags'/>
+ <return type='int' info='the number of nodes successfully adjusted or -1 in case of an error'/>
+ </function>
</symbols>
</api>
diff --git a/libvirt-override.c b/libvirt-override.c
index 872e33b..29cc8a9 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -8129,6 +8129,74 @@ libvirt_virDomainBlockCopy(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
#endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
+#if LIBVIR_CHECK_VERSION(1, 2, 9)
+static PyObject *
+libvirt_virNodeAllocPages(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args)
+{
+ PyObject *pyobj_conn;
+ PyObject *pyobj_pages;
+ Py_ssize_t size = 0;
+#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 4
+ int pos = 0;
+#else
+ Py_ssize_t pos = 0;
+#endif
+ PyObject *key, *value;
+ virConnectPtr conn;
+ unsigned int npages = 0;
+ unsigned int *pageSizes = NULL;
+ unsigned long long *pageCounts = NULL;
+ int startCell = -1;
+ unsigned int cellCount = 1;
+ unsigned int flags = VIR_NODE_ALLOC_PAGES_ADD;
+ int c_retval;
+
+ if (!PyArg_ParseTuple(args, (char *)"OOiii:virConnectGetAllDomainStats",
+ &pyobj_conn, &pyobj_pages,
+ &startCell, &cellCount, &flags))
+ return NULL;
+ conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
+
+ if ((size = PyDict_Size(pyobj_pages)) < 0)
+ return NULL;
+
+ if (size == 0) {
+ PyErr_Format(PyExc_LookupError,
+ "Need non-empty dictionary to pages attribute");
+ return NULL;
+ }
+
+ if (VIR_ALLOC_N(pageSizes, size) < 0 ||
+ VIR_ALLOC_N(pageCounts, size) < 0) {
+ PyErr_NoMemory();
+ goto error;
+ }
+
+ while (PyDict_Next(pyobj_pages, &pos, &key, &value)) {
+ if (libvirt_uintUnwrap(key, &pageSizes[npages]) < 0 ||
+ libvirt_ulonglongUnwrap(value, &pageCounts[npages]) < 0)
+ goto error;
+ npages++;
+ }
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_retval = virNodeAllocPages(conn, npages, pageSizes,
+ pageCounts, startCell, cellCount, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+
+ VIR_FREE(pageSizes);
+ VIR_FREE(pageCounts);
+
+ return libvirt_intWrap(c_retval);
+
+ error:
+ VIR_FREE(pageSizes);
+ VIR_FREE(pageCounts);
+ return NULL;
+}
+#endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
+
/************************************************************************
* *
* The registration stuff *
@@ -8319,6 +8387,9 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virDomainListGetStats", libvirt_virDomainListGetStats, METH_VARARGS, NULL},
{(char *) "virDomainBlockCopy", libvirt_virDomainBlockCopy, METH_VARARGS, NULL},
#endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
+#if LIBVIR_CHECK_VERSION(1, 2, 9)
+ {(char *) "virNodeAllocPages", libvirt_virNodeAllocPages, METH_VARARGS, NULL},
+#endif /* LIBVIR_CHECK_VERSION(1, 2, 9) */
{NULL, NULL, 0, NULL}
};
--
1.8.5.5
10 years, 3 months
[libvirt] [PATCH] qemuPrepareNVRAM: Save domain after NVRAM path generation
by Michal Privoznik
On a domain startup, the variable store path is generated if needed.
The path is intended to be generated only once. However, the updated
domain definition is not saved into config dir rather than state XML
only. So later, whenever the domain is destroyed and the daemon is
restarted, the generated path is forgotten and the file may be left
behind on virDomainUndefine() call.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_process.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index dddca35..1b8931e 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3876,6 +3876,9 @@ qemuPrepareNVRAM(virQEMUDriverConfigPtr cfg,
goto cleanup;
generated = true;
+
+ if (virDomainSaveConfig(cfg->configDir, def) < 0)
+ goto cleanup;
}
if (!virFileExists(loader->nvram)) {
--
1.8.5.5
10 years, 3 months
[libvirt] [PATCH] nodeinfo: fix version of nodeAllocPages
by Tomoki Sekiyama
Fix comments about the version in which '.nodeAllocPages' are added.
Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama(a)hds.com>
---
src/lxc/lxc_driver.c | 2 +-
src/qemu/qemu_driver.c | 2 +-
src/uml/uml_driver.c | 2 +-
src/vbox/vbox_common.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 38763de..b3e506f 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -5797,7 +5797,7 @@ static virDriver lxcDriver = {
.domainReboot = lxcDomainReboot, /* 1.0.1 */
.domainLxcOpenNamespace = lxcDomainLxcOpenNamespace, /* 1.0.2 */
.nodeGetFreePages = lxcNodeGetFreePages, /* 1.2.6 */
- .nodeAllocPages = lxcNodeAllocPages, /* 1.2.8 */
+ .nodeAllocPages = lxcNodeAllocPages, /* 1.2.9 */
};
static virStateDriver lxcStateDriver = {
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 117138a..d26b66a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -18416,7 +18416,7 @@ static virDriver qemuDriver = {
.nodeGetFreePages = qemuNodeGetFreePages, /* 1.2.6 */
.connectGetDomainCapabilities = qemuConnectGetDomainCapabilities, /* 1.2.7 */
.connectGetAllDomainStats = qemuConnectGetAllDomainStats, /* 1.2.8 */
- .nodeAllocPages = qemuNodeAllocPages, /* 1.2.8 */
+ .nodeAllocPages = qemuNodeAllocPages, /* 1.2.9 */
};
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index c255c07..2a40149 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -2980,7 +2980,7 @@ static virDriver umlDriver = {
.nodeGetMemoryParameters = umlNodeGetMemoryParameters, /* 0.10.2 */
.nodeSetMemoryParameters = umlNodeSetMemoryParameters, /* 0.10.2 */
.nodeGetFreePages = umlNodeGetFreePages, /* 1.2.6 */
- .nodeAllocPages = umlNodeAllocPages, /* 1.2.8 */
+ .nodeAllocPages = umlNodeAllocPages, /* 1.2.9 */
};
static virStateDriver umlStateDriver = {
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index e831255..7d75478 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -7551,7 +7551,7 @@ virDriver vboxCommonDriver = {
.domainSnapshotDelete = vboxDomainSnapshotDelete, /* 0.8.0 */
.connectIsAlive = vboxConnectIsAlive, /* 0.9.8 */
.nodeGetFreePages = vboxNodeGetFreePages, /* 1.2.6 */
- .nodeAllocPages = vboxNodeAllocPages, /* 1.2.8 */
+ .nodeAllocPages = vboxNodeAllocPages, /* 1.2.9 */
};
static void updateDriver(void)
10 years, 3 months
[libvirt] [PATCH] qemu: Always re-detect backing chain
by Peter Krempa
Since 363e9a68 we track backing chain metadata when creating snapshots
the right way even for the inactive configuration. As we did not yet
update other code paths that modify the backing chain (blockpull) the
newDef backing chain gets out of sync.
After stopping of a VM the new definition gets copied to the next start
one. The new VM then has incorrect backing chain info. This patch
switches the backing chain detector to always purge the existing backing
chain and forces re-detection to avoid this issue until we'll have full
backing chain tracking support.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1144922
---
src/qemu/qemu_domain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 11145d1..76fccce 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2540,7 +2540,7 @@ qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
virFileExists(virDomainDiskGetSource(disk)))
continue;
- if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) >= 0)
+ if (qemuDomainDetermineDiskChain(driver, vm, disk, true, true) >= 0)
continue;
if (disk->startupPolicy &&
--
2.1.0
10 years, 3 months
[libvirt] [PATCH] event_example: cleanup example code for tunable event
by Pavel Hrdina
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
examples/object-events/event-test.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/examples/object-events/event-test.c b/examples/object-events/event-test.c
index faf0cf2..0c6faf4 100644
--- a/examples/object-events/event-test.c
+++ b/examples/object-events/event-test.c
@@ -476,15 +476,6 @@ myDomainEventTunableCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
printf("%s EVENT: Domain %s(%d) tunable updated:\n",
__func__, virDomainGetName(dom), virDomainGetID(dom));
-#ifdef WIN32
-/* MinGW doesn't know the lld/llu so we have to use I64f/I64u instead. */
-# define LLD_FORMAT "%I64d"
-# define LLU_FORMAT "%I64u"
-#else /* WIN32 */
-# define LLD_FORMAT "%lld"
-# define LLU_FORMAT "%llu"
-#endif /* WIN32 */
-
for (i = 0; i < nparams; i++) {
switch (params[i].type) {
case VIR_TYPED_PARAM_INT:
@@ -494,10 +485,12 @@ myDomainEventTunableCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
printf("\t%s: %u\n", params[i].field, params[i].value.ui);
break;
case VIR_TYPED_PARAM_LLONG:
- printf("\t%s: " LLD_FORMAT "\n", params[i].field, params[i].value.l);
+ printf("\t%s: %" PRId64 "\n", params[i].field,
+ (int64_t) params[i].value.l);
break;
case VIR_TYPED_PARAM_ULLONG:
- printf("\t%s: " LLU_FORMAT "\n", params[i].field, params[i].value.ul);
+ printf("\t%s: %" PRIu64 "\n", params[i].field,
+ (uint64_t) params[i].value.ul);
break;
case VIR_TYPED_PARAM_DOUBLE:
printf("\t%s: %g\n", params[i].field, params[i].value.d);
--
1.8.5.5
10 years, 3 months
[libvirt] [PATCH] Rename tunable event constants
by Daniel P. Berrange
For the new VIR_DOMAIN_EVENT_ID_TUNABLE event we have a bunch of
constants added
VIR_DOMAIN_EVENT_CPUTUNE_<blah>
VIR_DOMAIN_EVENT_BLKDEVTUNE_<blah>
This naming convention is bad for two reasons
- There is no common prefix unique for the events to both
relate them, and distinguish them from other event
constants
- The values associated with the constants were chosen
to match the names used with virConnectGetAllDomainStats
so having EVENT in the constant name is not applicable in
that respect
This patch proposes renaming the constants to
VIR_DOMAIN_TUNABLE_CPU_<blah>
VIR_DOMAIN_TUNABLE_BLKDEV_<blah>
ie, given them a common VIR_DOMAIN_TUNABLE prefix.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
include/libvirt/libvirt.h.in | 56 ++++++++++++++++++++++----------------------
src/qemu/qemu_cgroup.c | 2 +-
src/qemu/qemu_driver.c | 28 +++++++++++-----------
3 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 93c9a48..2ff5204 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -5204,119 +5204,119 @@ typedef void (*virConnectDomainEventDeviceRemovedCallback)(virConnectPtr conn,
void *opaque);
/**
- * VIR_DOMAIN_EVENT_CPUTUNE_VCPUPIN:
+ * VIR_DOMAIN_TUNABLE_CPU_VCPUPIN:
*
* Macro represents formatted pinning for one vcpu specified by id which is
* appended to the parameter name, for example "cputune.vcpupin1",
* as VIR_TYPED_PARAM_STRING.
*/
-#define VIR_DOMAIN_EVENT_CPUTUNE_VCPUPIN "cputune.vcpupin%u"
+#define VIR_DOMAIN_TUNABLE_CPU_VCPUPIN "cputune.vcpupin%u"
/**
- * VIR_DOMAIN_EVENT_CPUTUNE_EMULATORIN:
+ * VIR_DOMAIN_TUNABLE_CPU_EMULATORIN:
*
* Macro represents formatted pinning for emulator process,
* as VIR_TYPED_PARAM_STRING.
*/
-#define VIR_DOMAIN_EVENT_CPUTUNE_EMULATORIN "cputune.emulatorpin"
+#define VIR_DOMAIN_TUNABLE_CPU_EMULATORIN "cputune.emulatorpin"
/**
- * VIR_DOMAIN_EVENT_CPUTUNE_CPU_SHARES:
+ * VIR_DOMAIN_TUNABLE_CPU_CPU_SHARES:
*
* Macro represents proportional weight of the scheduler used on the
* host cpu, when using the posix scheduler, as VIR_TYPED_PARAM_ULLONG.
*/
-#define VIR_DOMAIN_EVENT_CPUTUNE_CPU_SHARES "cputune.cpu_shares"
+#define VIR_DOMAIN_TUNABLE_CPU_CPU_SHARES "cputune.cpu_shares"
/**
- * VIR_DOMAIN_EVENT_CPUTUNE_VCPU_PERIOD:
+ * VIR_DOMAIN_TUNABLE_CPU_VCPU_PERIOD:
*
* Macro represents the enforcement period for a quota, in microseconds,
* for vcpus only, when using the posix scheduler, as VIR_TYPED_PARAM_ULLONG.
*/
-#define VIR_DOMAIN_EVENT_CPUTUNE_VCPU_PERIOD "cputune.vcpu_period"
+#define VIR_DOMAIN_TUNABLE_CPU_VCPU_PERIOD "cputune.vcpu_period"
/**
- * VIR_DOMAIN_EVENT_CPUTUNE_VCPU_QUOTA:
+ * VIR_DOMAIN_TUNABLE_CPU_VCPU_QUOTA:
*
* Macro represents the maximum bandwidth to be used within a period for
* vcpus only, when using the posix scheduler, as VIR_TYPED_PARAM_LLONG.
*/
-#define VIR_DOMAIN_EVENT_CPUTUNE_VCPU_QUOTA "cputune.vcpu_quota"
+#define VIR_DOMAIN_TUNABLE_CPU_VCPU_QUOTA "cputune.vcpu_quota"
/**
- * VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_PERIOD:
+ * VIR_DOMAIN_TUNABLE_CPU_EMULATOR_PERIOD:
*
* Macro represents the enforcement period for a quota in microseconds,
* when using the posix scheduler, for all emulator activity not tied to
* vcpus, as VIR_TYPED_PARAM_ULLONG.
*/
-#define VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_PERIOD "cputune.emulator_period"
+#define VIR_DOMAIN_TUNABLE_CPU_EMULATOR_PERIOD "cputune.emulator_period"
/**
- * VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_QUOTA:
+ * VIR_DOMAIN_TUNABLE_CPU_EMULATOR_QUOTA:
*
* Macro represents the maximum bandwidth to be used within a period for
* all emulator activity not tied to vcpus, when using the posix scheduler,
* as an VIR_TYPED_PARAM_LLONG.
*/
-#define VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_QUOTA "cputune.emulator_quota"
+#define VIR_DOMAIN_TUNABLE_CPU_EMULATOR_QUOTA "cputune.emulator_quota"
/**
- * VIR_DOMAIN_EVENT_BLKDEVIOTUNE_DISK:
+ * VIR_DOMAIN_TUNABLE_BLKDEV_DISK:
*
* Macro represents the name of guest disk for which the values are updated,
* as VIR_TYPED_PARAM_STRING.
*/
-#define VIR_DOMAIN_EVENT_BLKDEVIOTUNE_DISK "blkdeviotune.disk"
+#define VIR_DOMAIN_TUNABLE_BLKDEV_DISK "blkdeviotune.disk"
/**
- * VIR_DOMAIN_EVENT_BLKDEVIOTUNE_TOTAL_BYTES_SEC:
+ * VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_BYTES_SEC:
*
* Marco represents the total throughput limit in bytes per second,
* as VIR_TYPED_PARAM_ULLONG.
*/
-#define VIR_DOMAIN_EVENT_BLKDEVIOTUNE_TOTAL_BYTES_SEC "blkdeviotune.total_bytes_sec"
+#define VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_BYTES_SEC "blkdeviotune.total_bytes_sec"
/**
- * VIR_DOMAIN_EVENT_BLKDEVIOTUNE_READ_BYTES_SEC:
+ * VIR_DOMAIN_TUNABLE_BLKDEV_READ_BYTES_SEC:
*
* Marco represents the read throughput limit in bytes per second,
* as VIR_TYPED_PARAM_ULLONG.
*/
-#define VIR_DOMAIN_EVENT_BLKDEVIOTUNE_READ_BYTES_SEC "blkdeviotune.read_bytes_sec"
+#define VIR_DOMAIN_TUNABLE_BLKDEV_READ_BYTES_SEC "blkdeviotune.read_bytes_sec"
/**
- * VIR_DOMAIN_EVENT_BLKDEVIOTUNE_WRITE_BYTES_SEC:
+ * VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_BYTES_SEC:
*
* Macro represents the write throughput limit in bytes per second,
* as VIR_TYPED_PARAM_ULLONG.
*/
-#define VIR_DOMAIN_EVENT_BLKDEVIOTUNE_WRITE_BYTES_SEC "blkdeviotune.write_bytes_sec"
+#define VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_BYTES_SEC "blkdeviotune.write_bytes_sec"
/**
- * VIR_DOMAIN_EVENT_BLKDEVIOTUNE_TOTAL_IOPS_SEC:
+ * VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_IOPS_SEC:
*
* Macro represents the total I/O operations per second,
* as VIR_TYPED_PARAM_ULLONG.
*/
-#define VIR_DOMAIN_EVENT_BLKDEVIOTUNE_TOTAL_IOPS_SEC "blkdeviotune.total_iops_sec"
+#define VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_IOPS_SEC "blkdeviotune.total_iops_sec"
/**
- * VIR_DOMAIN_EVENT_BLKDEVIOTUNE_READ_IOPS_SEC:
+ * VIR_DOMAIN_TUNABLE_BLKDEV_READ_IOPS_SEC:
*
* Macro represents the read I/O operations per second,
* as VIR_TYPED_PARAM_ULLONG.
*/
-#define VIR_DOMAIN_EVENT_BLKDEVIOTUNE_READ_IOPS_SEC "blkdeviotune.read_iops_sec"
+#define VIR_DOMAIN_TUNABLE_BLKDEV_READ_IOPS_SEC "blkdeviotune.read_iops_sec"
/**
- * VIR_DOMAIN_EVENT_BLKDEVIOTUNE_WRITE_IOPS_SEC:
+ * VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_IOPS_SEC:
*
* Macro represents the write I/O operations per second,
* as VIR_TYPED_PARAM_ULLONG.
*/
-#define VIR_DOMAIN_EVENT_BLKDEVIOTUNE_WRITE_IOPS_SEC "blkdeviotune.write_iops_sec"
+#define VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_IOPS_SEC "blkdeviotune.write_iops_sec"
/**
* virConnectDomainEventTunableCallback:
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 300946a..8819943 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -703,7 +703,7 @@ qemuSetupCpuCgroup(virDomainObjPtr vm)
vm->def->cputune.shares = val;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxparams,
- VIR_DOMAIN_EVENT_CPUTUNE_CPU_SHARES,
+ VIR_DOMAIN_TUNABLE_CPU_CPU_SHARES,
val) < 0)
return -1;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 117138a..6e792a6 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4653,7 +4653,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
goto cleanup;
if (snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH,
- VIR_DOMAIN_EVENT_CPUTUNE_VCPUPIN, vcpu) < 0) {
+ VIR_DOMAIN_TUNABLE_CPU_VCPUPIN, vcpu) < 0) {
goto cleanup;
}
@@ -4940,7 +4940,7 @@ qemuDomainPinEmulator(virDomainPtr dom,
str = virBitmapFormat(pcpumap);
if (virTypedParamsAddString(&eventParams, &eventNparams,
&eventMaxparams,
- VIR_DOMAIN_EVENT_CPUTUNE_EMULATORIN,
+ VIR_DOMAIN_TUNABLE_CPU_EMULATORIN,
str) < 0)
goto cleanup;
@@ -9318,7 +9318,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxNparams,
- VIR_DOMAIN_EVENT_CPUTUNE_CPU_SHARES,
+ VIR_DOMAIN_TUNABLE_CPU_CPU_SHARES,
val) < 0)
goto cleanup;
}
@@ -9341,7 +9341,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxNparams,
- VIR_DOMAIN_EVENT_CPUTUNE_VCPU_PERIOD,
+ VIR_DOMAIN_TUNABLE_CPU_VCPU_PERIOD,
value_ul) < 0)
goto cleanup;
}
@@ -9361,7 +9361,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
if (virTypedParamsAddLLong(&eventParams, &eventNparams,
&eventMaxNparams,
- VIR_DOMAIN_EVENT_CPUTUNE_VCPU_QUOTA,
+ VIR_DOMAIN_TUNABLE_CPU_VCPU_QUOTA,
value_l) < 0)
goto cleanup;
}
@@ -9382,7 +9382,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxNparams,
- VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_PERIOD,
+ VIR_DOMAIN_TUNABLE_CPU_EMULATOR_PERIOD,
value_ul) < 0)
goto cleanup;
}
@@ -9403,7 +9403,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
if (virTypedParamsAddLLong(&eventParams, &eventNparams,
&eventMaxNparams,
- VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_QUOTA,
+ VIR_DOMAIN_TUNABLE_CPU_EMULATOR_QUOTA,
value_l) < 0)
goto cleanup;
}
@@ -16321,7 +16321,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
goto endjob;
if (virTypedParamsAddString(&eventParams, &eventNparams, &eventMaxparams,
- VIR_DOMAIN_EVENT_BLKDEVIOTUNE_DISK, disk) < 0)
+ VIR_DOMAIN_TUNABLE_BLKDEV_DISK, disk) < 0)
goto endjob;
for (i = 0; i < nparams; i++) {
@@ -16339,7 +16339,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
set_bytes = true;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxparams,
- VIR_DOMAIN_EVENT_BLKDEVIOTUNE_TOTAL_BYTES_SEC,
+ VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_BYTES_SEC,
param->value.ul) < 0)
goto endjob;
} else if (STREQ(param->field,
@@ -16348,7 +16348,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
set_bytes = true;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxparams,
- VIR_DOMAIN_EVENT_BLKDEVIOTUNE_READ_BYTES_SEC,
+ VIR_DOMAIN_TUNABLE_BLKDEV_READ_BYTES_SEC,
param->value.ul) < 0)
goto endjob;
} else if (STREQ(param->field,
@@ -16357,7 +16357,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
set_bytes = true;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxparams,
- VIR_DOMAIN_EVENT_BLKDEVIOTUNE_WRITE_BYTES_SEC,
+ VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_BYTES_SEC,
param->value.ul) < 0)
goto endjob;
} else if (STREQ(param->field,
@@ -16366,7 +16366,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
set_iops = true;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxparams,
- VIR_DOMAIN_EVENT_BLKDEVIOTUNE_TOTAL_IOPS_SEC,
+ VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_IOPS_SEC,
param->value.ul) < 0)
goto endjob;
} else if (STREQ(param->field,
@@ -16375,7 +16375,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
set_iops = true;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxparams,
- VIR_DOMAIN_EVENT_BLKDEVIOTUNE_READ_IOPS_SEC,
+ VIR_DOMAIN_TUNABLE_BLKDEV_READ_IOPS_SEC,
param->value.ul) < 0)
goto endjob;
} else if (STREQ(param->field,
@@ -16384,7 +16384,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
set_iops = true;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxparams,
- VIR_DOMAIN_EVENT_BLKDEVIOTUNE_WRITE_IOPS_SEC,
+ VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_IOPS_SEC,
param->value.ul) < 0)
goto endjob;
}
--
1.9.3
10 years, 3 months
[libvirt] [PATCH] lxc_monitor_protocol: Redefine xdr_uint64_t if needed
by Michal Privoznik
On some systems (using libtirpc instead of glibc's
implementation), xdr_uint64_t exists rather under different name:
xdr_u_int64_t. This makes compilation fail then:
libvirt_lxc-lxc_monitor_protocol.o: In function `xdr_virLXCMonitorInitEventMsg':
/usr/local/src/libvirt/libvirt-1.1.1/src/./lxc/lxc_monitor_protocol.c:31: undefined reference to `xdr_uint64_t'
Therefore we rather mirror the d707c866 commit and redefine
xdr_uint64_t if needed.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/lxc/lxc_monitor_protocol.x | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/src/lxc/lxc_monitor_protocol.x b/src/lxc/lxc_monitor_protocol.x
index 0926e26..3b66af5 100644
--- a/src/lxc/lxc_monitor_protocol.x
+++ b/src/lxc/lxc_monitor_protocol.x
@@ -4,6 +4,25 @@
* the libvirt_lxc helper program.
*/
+/* cygwin's xdr implementation defines xdr_u_int64_t instead of xdr_uint64_t
+ * and lacks IXDR_PUT_INT32 and IXDR_GET_INT32
+ */
+%#ifdef HAVE_XDR_U_INT64_T
+%# define xdr_uint64_t xdr_u_int64_t
+%#endif
+%#ifndef IXDR_PUT_INT32
+%# define IXDR_PUT_INT32 IXDR_PUT_LONG
+%#endif
+%#ifndef IXDR_GET_INT32
+%# define IXDR_GET_INT32 IXDR_GET_LONG
+%#endif
+%#ifndef IXDR_PUT_U_INT32
+%# define IXDR_PUT_U_INT32 IXDR_PUT_U_LONG
+%#endif
+%#ifndef IXDR_GET_U_INT32
+%# define IXDR_GET_U_INT32 IXDR_GET_U_LONG
+%#endif
+
enum virLXCMonitorExitStatus {
VIR_LXC_MONITOR_EXIT_STATUS_ERROR,
VIR_LXC_MONITOR_EXIT_STATUS_SHUTDOWN,
--
1.8.5.5
10 years, 3 months
[libvirt] [PATCH] remoteNodeGetFreePages: Don't alloc args.pages.pages_val
by Michal Privoznik
There's no one to free() it anyway. Instead, we can just pass the
provided array pointer directly.
==20039== 48 bytes in 4 blocks are definitely lost in loss record 658 of 787
==20039== at 0x4C2A700: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==20039== by 0x4EA661F: virAllocN (viralloc.c:191)
==20039== by 0x50386EF: remoteNodeGetFreePages (remote_driver.c:7625)
==20039== by 0x5003504: virNodeGetFreePages (libvirt.c:21379)
==20039== by 0x154625: cmdFreepages (virsh-host.c:374)
==20039== by 0x12F718: vshCommandRun (virsh.c:1935)
==20039== by 0x1339FB: main (virsh.c:3747)
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/remote/remote_driver.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index dc2d2fb..6c49e49 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -7622,9 +7622,7 @@ remoteNodeGetFreePages(virConnectPtr conn,
goto done;
}
- if (VIR_ALLOC_N(args.pages.pages_val, npages) < 0)
- goto done;
- memcpy(args.pages.pages_val, pages, npages * sizeof(*pages));
+ args.pages.pages_val = (u_int *) pages;
args.pages.pages_len = npages;
args.startCell = startCell;
args.cellCount = cellCount;
--
1.8.5.5
10 years, 3 months
[libvirt] [PATCH] virNodeAllocPages: Disallow RO connection
by Michal Privoznik
Due to a missing check the API can be successfully called even if
the connection is ReadOnly. Fortunately, the API hasn't been
released yet, so there's no need for a CVE.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/libvirt.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/libvirt.c b/src/libvirt.c
index 388c040..245c373 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -21893,6 +21893,7 @@ virNodeAllocPages(virConnectPtr conn,
virResetLastError();
virCheckConnectReturn(conn, -1);
+ virCheckReadOnlyGoto(conn->flags, error);
virCheckNonZeroArgGoto(npages, error);
virCheckNonNullArgGoto(pageSizes, error);
virCheckNonNullArgGoto(pageCounts, error);
--
1.8.5.5
10 years, 3 months
Re: [libvirt] [PATCH virt-manager] details: Add UI for enabling UEFI via 'customize before install'
by Laszlo Ersek
Hi Cole and Michal,
I'm attaching three patches:
On 09/20/14 02:37, Cole Robinson wrote:
> On 09/17/2014 06:55 PM, Cole Robinson wrote:
>> We expose a simple combobox with two entries: BIOS, and UEFI. The
>> UEFI option is only selectable if 1) libvirt supports the necessary
>> domcapabilities bits, 2) it detects that qemu supports the necessary
>> command line options, and 3) libvirt detects a UEFI binary on the
>> host that maps to a known template via qemu.conf
>>
>> If those conditions aren't met, we disable the UEFI option, and show
>> a small warning icon with an explanatory tooltip.
>>
>> The option can only be changed via New VM->Customize Before Install.
>> For existing x86 VMs, it's a readonly label.
>
> I've pushed this now, with follow up patches to handle a couple points
> we discussed:
>
> - Remove the nvram deletion from delete.py, since it won't work in the
> non-root case, and all uses of nvram should also be with a libvirt +
> driver that provides UNDEFINE_NVRAM
>
> - Before using UNDEFINE_NVRAM, match the same condition that libvirt
> uses: loader_ro is True and loader_type == "pflash" and bool(nvram)
(1) unfortunately virt-manager commit 3feedb76 ("domain: Match
UNDEFINE_NVRAM conditions with libvirt") is not correct (it doesn't
work), and not what I had in mind:
> diff --git a/virtManager/domain.py b/virtManager/domain.py
> index 29f3861..abf3146 100644
> --- a/virtManager/domain.py
> +++ b/virtManager/domain.py
> @@ -1403,7 +1403,9 @@ class vmmDomain(vmmLibvirtObject):
> flags |= getattr(libvirt,
> "VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA", 0)
> flags |= getattr(libvirt, "VIR_DOMAIN_UNDEFINE_MANAGED_SAVE", 0)
> - if self.get_xmlobj().os.nvram:
> + if (self.get_xmlobj().os.loader_ro is True and
> + self.get_xmlobj().os.loader_type == "pflash" and
> + self.get_xmlobj().os.nvram):
> flags |= getattr(libvirt, "VIR_DOMAIN_UNDEFINE_NVRAM", 0)
> try:
> self._backend.undefineFlags(flags)
Before virt-manager commit 3feedb76, the condition on which to set the
flag was:
self.get_xmlobj().os.nvram
and it didn't work for all possible cases.
After the patch, what you have is
self.get_xmlobj().os.nvram *and* blah
The commit only constrains (further tightens, further restricts) the
original condition, which had been too restrictive to begin with. Again,
the nvram element (or its text() child) can be completely absent from
the domain XML -- libvirtd will generate the pathname of the varstore
file on the fly, and it need not be part of the serialized XML file. So
in the XML all you'll have is
<os>
<type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
<loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
<boot dev='cdrom'/>
</os>
or
<os>
<type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
<loader readonly='yes' type='pflash'>/custom/OVMF_CODE.fd</loader>
<nvram template='/custom/OVMF_VARS.fd'/>
<boot dev='cdrom'/>
</os>
My suggestion was to *replace* the original condition with the
(loader_ro && loader_type=="pflash") one. If you check my earlier
message, I wrote *iff*, meaning "if and only if".
Cole, can you please apply the first attached patch?
(2) Unfortunately, even libvirtd needs to be modified, in addition.
My patch for (1) *does* pass VIR_DOMAIN_UNDEFINE_NVRAM to libvirtd (I
verified that with gdb), but libvirtd doesn't act upon it correctly.
Namely, in the libvirtd source code, in qemuDomainUndefineFlags(),
commit 273b6581 added:
if (!virDomainObjIsActive(vm) &&
vm->def->os.loader && vm->def->os.loader->nvram &&
virFileExists(vm->def->os.loader->nvram)) {
if (!(flags & VIR_DOMAIN_UNDEFINE_NVRAM)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot delete inactive domain with nvram"));
goto cleanup;
}
if (unlink(vm->def->os.loader->nvram) < 0) {
virReportSystemError(errno,
_("failed to remove nvram: %s"),
vm->def->os.loader->nvram);
goto cleanup;
}
}
Here "vm->def->os.loader->nvram" evaluates to NULL:
6468 if (!virDomainObjIsActive(vm) &&
6469 vm->def->os.loader && vm->def->os.loader->nvram &&
6470 virFileExists(vm->def->os.loader->nvram)) {
6471 if (!(flags & VIR_DOMAIN_UNDEFINE_NVRAM)) {
6472 virReportError(VIR_ERR_OPERATION_INVALID, "%s",
(gdb) print vm->def->os.loader
$1 = (virDomainLoaderDefPtr) 0x7ff59c00bf20
(gdb) print vm->def->os.loader->nvram
$2 = 0x0
I thought that the auto-generation of the nvram pathname (internal to
libvirtd, ie. not visible in the XML file) would occur on the undefine
path as well. Apparently this is not the case.
Indeed, the only call to qemuPrepareNVRAM() is from qemuProcessStart().
Michal, would it be possible generate the *pathname* of the separate
varstore in qemuDomainUndefineFlags() too?
Please see the second attached patch; it works for me. (This patch is
best looked at with "git diff -b" (or "git show -b").)
(3) I just realized that a domain's name can change during its lifetime.
Renaming a domain becomes a problem when the varstore's pathname is
deduced from the domain's name. For this reason, the auto-generation
should use the domain's UUID (which never changes). Michal, what do you
think of the 3rd attached patch?
I can resubmit these as standalone patches / series as well (the first
to virt-tools-list, and the last two to libvir-list), if that's
necessary.
Thanks,
Laszlo
10 years, 3 months