[libvirt] [PATCH 0/2] Forbid negative blkio device values
by Martin Kletzander
Commits 0728d472 and 399394ab added suuport for
VIR_DOMAIN_BLKIO_DEVICE_*, but all the values were parsed with
underflow being allowed. Since there is no point in that, it should
be fixed. Unfortunately the code is duplicated (apart from passing
device/value pairs as a string :-/), so it needs to be fixed twice.
This "series" fixes https://bugzilla.redhat.com/show_bug.cgi?id=1131306
Martin Kletzander (2):
lxc: forbid negative blkio values
qemu: forbid negative blkio values
src/lxc/lxc_driver.c | 8 ++++----
src/qemu/qemu_driver.c | 10 +++++-----
2 files changed, 9 insertions(+), 9 deletions(-)
--
2.0.4
10 years, 4 months
[libvirt] [PATCH] qemu: Fix build error introduced in 653137eb957a278b556c6226424aad5395a
by Peter Krempa
The build failure is caused by a false positive of some static analysys
steps done by gcc (that don't happen on -O0).
---
src/qemu/qemu_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c011151..801044b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15807,7 +15807,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
int ret = -1;
size_t i;
int idx = -1;
- int conf_idx;
+ int conf_idx = -1;
bool set_bytes = false;
bool set_iops = false;
virQEMUDriverConfigPtr cfg = NULL;
--
2.0.2
10 years, 4 months
[libvirt] [PATCH] qemu: blkiotune: Avoid accessing non-existing disk configuration
by Peter Krempa
When a user would try changing the persistent IO tuning settings for a
disk that was hotplugged to a vm in a transient way, the
qemuDomainSetBlockIoTune API would use the same index for both the
live and config disk array. The disk was missing from the config array
though causing a crash of libvirtd.
To fix the issue, determine the indexes separately.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1131819
---
src/qemu/qemu_driver.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0aa1393..c011151 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15807,6 +15807,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
int ret = -1;
size_t i;
int idx = -1;
+ int conf_idx;
bool set_bytes = false;
bool set_iops = false;
virQEMUDriverConfigPtr cfg = NULL;
@@ -15848,9 +15849,6 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto endjob;
- if (!(device = qemuDiskPathToAlias(vm, disk, &idx)))
- goto endjob;
-
if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags,
&persistentDef) < 0)
goto endjob;
@@ -15905,6 +15903,15 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
goto endjob;
}
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
+ if ((conf_idx = virDomainDiskIndexByName(persistentDef, disk, true)) < 0) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("missing persistent configuration for disk '%s'"),
+ disk);
+ goto endjob;
+ }
+ }
+
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DRIVE_IOTUNE)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -15913,6 +15920,9 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
goto endjob;
}
+ if (!(device = qemuDiskPathToAlias(vm, disk, &idx)))
+ goto endjob;
+
/* If the user didn't specify bytes limits, inherit previous
* values; likewise if the user didn't specify iops
* limits. */
@@ -15937,7 +15947,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
sa_assert(persistentDef);
- oldinfo = &persistentDef->disks[idx]->blkdeviotune;
+ oldinfo = &persistentDef->disks[conf_idx]->blkdeviotune;
if (!set_bytes) {
info.total_bytes_sec = oldinfo->total_bytes_sec;
info.read_bytes_sec = oldinfo->read_bytes_sec;
@@ -15948,7 +15958,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
info.read_iops_sec = oldinfo->read_iops_sec;
info.write_iops_sec = oldinfo->write_iops_sec;
}
- persistentDef->disks[idx]->blkdeviotune = info;
+ persistentDef->disks[conf_idx]->blkdeviotune = info;
ret = virDomainSaveConfig(cfg->configDir, persistentDef);
if (ret < 0) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
--
2.0.2
10 years, 4 months
[libvirt] A question about scsi controller index
by Wang Rui
Hi, all
I define a VM with a virtio scsi disk and I specify a controller index.
<disk type='file' device='disk'>
<driver name='qemu' type='raw' cache='none' io='native'/>
<source file='/mnt/sdb/wangrui/img/sles10_sp3_32_2U-5'/>
<target dev='sdb' bus='scsi'/>
<address type='drive' controller='10' bus='0' target='0' unit='1'/>
</disk>
Controllers 0-10 are created(in virDomainDefAddDiskControllersForType())
although I have only one scsi disk.
Are the controllers 0-9 useful for some reason?
If the user specifies controller='n', it will cost extra time and memory
for creating controllers from 0 to n-1. It becomes worse if n is a very
large value (Usually it's the user's wrong configuration). I think if
controllers from 0 to n-1 are kept for other use , we should better to
check whether n is meaningless(A very large number is meaningless).
BTW, I modify this function. Only the specified index controller will be
created. It seems to work fine.
10 years, 4 months
[libvirt] [PATCH] libxl: do not use hardcoded pygrub path
by Alvaro Lopez Garcia
According to the Xen documentation the full path was only needed
for versions prior to 4.1: "Note: For older versions of Xen Project
software (4.1 or earlier) you need to know where in the filesystem
pygrub lies. (...) Newer versions of the toolstack know how to look
for the path themselves." [1]
[1] http://wiki.xen.org/wiki/PyGrub
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1104695
Signed-off-by: Alvaro Lopez Garcia <aloga(a)ifca.unican.es>
---
src/libxl/libxl_conf.c | 13 +++++++++++--
src/libxl/libxl_conf.h | 5 ++++-
src/libxl/libxl_domain.c | 2 +-
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 1210500..896ea8d 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -100,6 +100,7 @@ libxlDriverConfigDispose(void *obj)
VIR_FREE(cfg->libDir);
VIR_FREE(cfg->saveDir);
VIR_FREE(cfg->autoDumpDir);
+ VIR_FREE(cfg->bootloader);
}
static int
@@ -570,6 +571,7 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf)
static int
libxlMakeDomBuildInfo(virDomainDefPtr def,
+ libxlDriverConfigPtr cfg,
libxl_ctx *ctx,
libxl_domain_config *d_config)
{
@@ -688,7 +690,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
if (VIR_STRDUP(b_info->u.pv.bootloader, def->os.bootloader) < 0)
goto error;
} else if (def->os.kernel == NULL) {
- if (VIR_STRDUP(b_info->u.pv.bootloader, LIBXL_BOOTLOADER_PATH) < 0)
+ if (VIR_STRDUP(b_info->u.pv.bootloader, cfg->bootloader) < 0)
goto error;
}
if (def->os.bootloaderArgs) {
@@ -1241,6 +1243,12 @@ libxlDriverConfigNew(void)
cfg->version = (cfg->verInfo->xen_version_major * 1000000) +
(cfg->verInfo->xen_version_minor * 1000);
+ /*
+ * Versions prior to 4.2 need the full pygrub path
+ */
+ if (VIR_STRDUP(cfg->bootloader, cfg->version >= 4002000 ? LIBXL_BOOTLOADER : LIBXL_BOOTLOADER_PATH) < 0)
+ goto error;
+
/* This will fill xenstore info about free and dom0 memory if missing,
* should be called before starting first domain */
if (libxl_get_free_memory(cfg->ctx, &free_mem)) {
@@ -1399,6 +1407,7 @@ libxlMakeCapabilities(libxl_ctx *ctx)
int
libxlBuildDomainConfig(virPortAllocatorPtr graphicsports,
virDomainDefPtr def,
+ libxlDriverConfigPtr cfg,
libxl_ctx *ctx,
libxl_domain_config *d_config)
{
@@ -1407,7 +1416,7 @@ libxlBuildDomainConfig(virPortAllocatorPtr graphicsports,
if (libxlMakeDomCreateInfo(ctx, def, &d_config->c_info) < 0)
return -1;
- if (libxlMakeDomBuildInfo(def, ctx, d_config) < 0)
+ if (libxlMakeDomBuildInfo(def, cfg, ctx, d_config) < 0)
return -1;
if (libxlMakeDiskList(def, d_config) < 0)
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index da66b4e..9d18c4b 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -53,7 +53,8 @@
# define LIBXL_LIB_DIR LOCALSTATEDIR "/lib/libvirt/libxl"
# define LIBXL_SAVE_DIR LIBXL_LIB_DIR "/save"
# define LIBXL_DUMP_DIR LIBXL_LIB_DIR "/dump"
-# define LIBXL_BOOTLOADER_PATH BINDIR "/pygrub"
+# define LIBXL_BOOTLOADER "pygrub"
+# define LIBXL_BOOTLOADER_PATH BINDIR "/" LIBXL_BOOTLOADER
/* libxl interface for setting VCPU affinity changed in 4.5. In fact, a new
* parameter has been added, representative of 'VCPU soft affinity'. If one
@@ -99,6 +100,7 @@ struct _libxlDriverConfig {
char *libDir;
char *saveDir;
char *autoDumpDir;
+ char *bootloader;
};
@@ -181,6 +183,7 @@ libxlCreateXMLConf(void);
int
libxlBuildDomainConfig(virPortAllocatorPtr graphicsports,
virDomainDefPtr def,
+ libxlDriverConfigPtr cfg,
libxl_ctx *ctx,
libxl_domain_config *d_config);
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index cdac82c..14f048a 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -1199,7 +1199,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
VIR_FREE(managed_save_path);
}
- if (libxlBuildDomainConfig(driver->reservedVNCPorts, vm->def,
+ if (libxlBuildDomainConfig(driver->reservedVNCPorts, vm->def, cfg,
priv->ctx, &d_config) < 0)
goto endjob;
--
2.1.0.rc1
10 years, 4 months
[libvirt] [PATCHv2 libvirt] qemu: Issue rtc-reset-reinjection command after guest-set-time
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=1103245
An advice appeared there on the qemu-devel list [1]. When a domain is
suspended and then resumed guest kernel is not aware of this. So we've
introduced virDomainSetTime API that resets the time within guest
using qemu-ga. On the other hand, qemu itself is trying to make RTC
beat faster to catch the difference. But if we don't tell qemu that
guest's time was reset via the other method, both mechanisms are
applied resulting in again wrong guest time. In order to avoid summing
both corrections we need to tell qemu that it should not use the RTC
injection if the guest time is set via guest agent.
1: http://www.mail-archive.com/qemu-devel@nongnu.org/msg236435.html
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Notes:
diff to v1:
-fixed command name in subject
-added testcase
src/qemu/qemu_driver.c | 10 ++++++++++
src/qemu/qemu_monitor.c | 33 +++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor.h | 2 ++
src/qemu/qemu_monitor_json.c | 21 +++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 2 ++
tests/qemumonitorjsontest.c | 1 +
6 files changed, 69 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b6219ba..bdfd155 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16879,6 +16879,16 @@ qemuDomainSetTime(virDomainPtr dom,
rv = qemuAgentSetTime(priv->agent, seconds, nseconds, rtcSync);
qemuDomainObjExitAgent(vm);
+ if (!virDomainObjIsActive(vm)) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto endjob;
+ }
+
+ qemuDomainObjEnterMonitor(driver, vm);
+ rv = qemuMonitorRTCResetReinjection(priv->mon);
+ qemuDomainObjExitMonitor(driver, vm);
+
if (rv < 0)
goto endjob;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 3d9f87b..77627bc 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -4037,3 +4037,36 @@ qemuMonitorGetGuestCPU(qemuMonitorPtr mon,
return qemuMonitorJSONGetGuestCPU(mon, arch, data);
}
+
+/**
+ * qemuMonitorRTCResetReinjection:
+ * @mon: Pointer to the monitor
+ *
+ * Issue rtc-reset-reinjection command.
+ * This should be used in cases where guest time is restored via
+ * guest agent so RTC injection is not needed (in fact it will
+ * confuse guest's RTC).
+ *
+ * Returns 0 on success
+ * -1 on error.
+ */
+int
+qemuMonitorRTCResetReinjection(qemuMonitorPtr mon)
+{
+
+ VIR_DEBUG("mon=%p", mon);
+
+ if (!mon) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("monitor must not be NULL"));
+ return -1;
+ }
+
+ if (!mon->json) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("JSON monitor is required"));
+ return -1;
+ }
+
+ return qemuMonitorJSONRTCResetReinjection(mon);
+}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index c3695f2..4fd6f01 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -790,6 +790,8 @@ int qemuMonitorGetGuestCPU(qemuMonitorPtr mon,
virArch arch,
virCPUDataPtr *data);
+int qemuMonitorRTCResetReinjection(qemuMonitorPtr mon);
+
/**
* When running two dd process and using <> redirection, we need a
* shell that will not truncate files. These two strings serve that
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index a62c02f..538110c 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -5851,3 +5851,24 @@ qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon,
return -1;
}
}
+
+int
+qemuMonitorJSONRTCResetReinjection(qemuMonitorPtr mon)
+{
+ int ret = -1;
+ virJSONValuePtr cmd;
+ virJSONValuePtr reply = NULL;
+
+ if (!(cmd = qemuMonitorJSONMakeCommand("rtc-reset-reinjection",
+ NULL)))
+ return ret;
+
+ ret = qemuMonitorJSONCommand(mon, cmd, &reply);
+
+ if (ret == 0)
+ ret = qemuMonitorJSONCheckError(cmd, reply);
+
+ virJSONValueFree(cmd);
+ virJSONValueFree(reply);
+ return ret;
+}
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 5f6c846..d8c9308 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -437,4 +437,6 @@ int qemuMonitorJSONGetDeviceAliases(qemuMonitorPtr mon,
int qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon,
virArch arch,
virCPUDataPtr *data);
+
+int qemuMonitorJSONRTCResetReinjection(qemuMonitorPtr mon);
#endif /* QEMU_MONITOR_JSON_H */
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index baee80a..e3fb4f7 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -2279,6 +2279,7 @@ mymain(void)
DO_TEST_SIMPLE("inject-nmi", qemuMonitorJSONInjectNMI);
DO_TEST_SIMPLE("system_wakeup", qemuMonitorJSONSystemWakeup);
DO_TEST_SIMPLE("nbd-server-stop", qemuMonitorJSONNBDServerStop);
+ DO_TEST_SIMPLE("rtc-reset-reinjection", qemuMonitorJSONRTCResetReinjection);
DO_TEST_GEN(qemuMonitorJSONSetLink);
DO_TEST_GEN(qemuMonitorJSONBlockResize);
DO_TEST_GEN(qemuMonitorJSONSetVNCPassword);
--
1.8.5.5
10 years, 4 months
[libvirt] [PATCH 00/14] qemu: Cdrom media change fixes and support for networked storage
by Peter Krempa
Peter Krempa (14):
qemu: Explicitly state that hotplugging cdroms and floppies doesn't
work
conf: Pass virStorageSource into virDomainDiskSourceIsBlockType
qemu: hotplug: Untangle cleanup paths in
qemuDomainChangeEjectableMedia
qemu: hotplug: Add helper to initialize/teardown new disks for VMs
qemu: hotplug: Change arguments for qemuDomainChangeEjectableMedia
qemu: hotplug: Format proper source string for cdrom media change
qemu: shared: Split out insertion code to the shared device list
qemu: shared: Split out shared device list remove code
qemu: conf: rename qemuCheckSharedDevice to qemuCheckSharedDisk
qemu: conf: Split up qemuAddSharedDevice into per-device-type
functions
qemu: conf: Split up qemuRemoveSharedDevice into per-device-type
functions
qemu: conf: Split out code to retrieve hostdev key and reuse it
qemu: hotplug: Sanitize shared device removal on media change
qemu: hotplug: Reject media change when XML contains disk ABI change
src/conf/domain_conf.c | 21 +--
src/conf/domain_conf.h | 5 +-
src/libvirt_private.syms | 1 +
src/lxc/lxc_cgroup.c | 2 +-
src/lxc/lxc_driver.c | 2 +-
src/qemu/qemu_command.c | 2 +-
src/qemu/qemu_conf.c | 445 ++++++++++++++++++++++++-----------------------
src/qemu/qemu_conf.h | 5 +
src/qemu/qemu_driver.c | 43 ++---
src/qemu/qemu_hotplug.c | 269 +++++++++++++++-------------
src/qemu/qemu_hotplug.h | 3 +-
11 files changed, 414 insertions(+), 384 deletions(-)
--
2.0.2
10 years, 4 months
[libvirt] [PATCH V1 0/2] cpu: Handle only high order 16 bits of PVR for IBM
by Pradipta Kr. Banerjee
Handle only high order 16 bits of PVR for IBM Power processors
Pradipta Kr. Banerjee (2):
cpu: Handle only high order 16 bits of PVR for IBM Power processors
cpu_map.xml: Add base POWER8 processor details
src/cpu/cpu_map.xml | 5 +++++
src/cpu/cpu_powerpc.c | 7 ++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
--
1.9.3
10 years, 4 months
[libvirt] How to install libvirt-python from source code?
by Can Zhang
Hi,
I’d like to install a latest version libvirt on CentOS 6.5. I compiled libvirt, it worked well and then I tried to install libvirt-python.
The version is libvirt-python-1.2.7, and I used `python setup.py build` and `sudo python setup.py install` to install.
But in python, I get errors like:
==========
>>> import libvirt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.6/site-packages/libvirt.py", line 28, in <module>
raise lib_e
ImportError: /usr/lib64/python2.6/site-packages/libvirtmod.so: undefined symbol: virTypedParamsAddBoolean
==========
Someone would help?
Best regards,
Can Zhang
10 years, 4 months
[libvirt] [PATCH v2 libvirt 0/8] Add support for qemu usb-mtp device
by Giuseppe Scrivano
This series adds support for qemu usb-mtp devices.
This new series addresses comments for v1:
https://www.redhat.com/archives/libvir-list/2014-August/msg00381.html
Now the XML looks like:
<filesystem type='mount'>
<source dir='/tmp/mtp_root'/>
<model type='mtp'/>
<target dir='mtp share'/>
</filesystem>
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1121781
Giuseppe Scrivano (8):
conf: add <model> child element to <filesystem>
conf, virDomainFSDefPtr: rename "path" argument to "target"
qemu_command: fix block indentation
qemu: add support for MTP filesystem
docs: add documentation and schema for <filesystem>/<model>
docs: relax <filesystem>/<target> dir element attribute to string
conf: fix comment
tests: add tests for filesystem model mtp
docs/formatdomain.html.in | 6 +++
docs/schemas/domaincommon.rng | 17 ++++++--
src/conf/domain_conf.c | 29 ++++++++++++-
src/conf/domain_conf.h | 15 ++++++-
src/qemu/qemu_command.c | 74 +++++++++++++++++++---------------
tests/domainconfdata/getfilesystem.xml | 5 +++
tests/domainconftest.c | 1 +
7 files changed, 108 insertions(+), 39 deletions(-)
--
1.9.3
10 years, 4 months