[libvirt] [PATCH] qemu: fix crash in migrate when migrateuri do not have a scheme
by Luyao Huang
https://bugzilla.redhat.com/show_bug.cgi?id=1191355
When we migrate a vm with migrateuri option with a uri do not
have scheme like this:
# virsh migrate test4 --live qemu+ssh://lhuang/system --migrateuri 127.0.0.1
target libvirtd will crashed because uri->scheme is NULL in
qemuMigrationPrepareDirect this line:
if (STRNEQ(uri->scheme, "tcp") &&
add a value check before this line.
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
src/qemu/qemu_migration.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 879b1bf..5c3b73e 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3281,6 +3281,13 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
if (!(uri = qemuMigrationParseURI(uri_in, &well_formed_uri)))
goto cleanup;
+ if (uri->scheme == NULL) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("missing scheme in migration URI: %s"),
+ uri_in);
+ goto cleanup;
+ }
+
if (STRNEQ(uri->scheme, "tcp") &&
STRNEQ(uri->scheme, "rdma")) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
--
1.8.3.1
9 years, 9 months
[libvirt] [PATCH] storage: rbd: Improve the error when start a pool based on non-exist rados object
by Shanzhi Yu
When start/create a pool based on non-exist rados object, the error will be like
$virsh pool-start p-c
error: Failed to start pool p-c
error: failed to create the RBD IoCTX. Does the pool 'libvirt-pool-clone' exist?: No such file or directory
update it to
error: Failed to start pool p-c
error: internal error: failed to create the RBD IoCTX. the rados pool 'libvirt-pool-clone' is not available
Signed-off-by: Shanzhi Yu <shyu(a)redhat.com>
---
src/storage/storage_backend_rbd.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index 57182de..98e7fe7 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -236,8 +236,10 @@ static int virStorageBackendRBDOpenIoCTX(virStorageBackendRBDStatePtr ptr, virSt
{
int r = rados_ioctx_create(ptr->cluster, pool->def->source.name, &ptr->ioctx);
if (r < 0) {
- virReportSystemError(-r, _("failed to create the RBD IoCTX. Does the pool '%s' exist?"),
- pool->def->source.name);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("failed to create the RBD IoCTX. "
+ "the rados pool '%s' is not available"),
+ pool->def->source.name);
}
return r;
}
--
2.1.0
9 years, 9 months
[libvirt] [PATCH] virsh: fix show the wrong IP address for network type listen address graphic
by Luyao Huang
https://bugzilla.redhat.com/show_bug.cgi?id=1191016
We try to get the IP address in /domain/devices/graphics/@listen, howerver
for the network type listen address donnot have this parameter, it will
show the address in the /domain/devices/graphics/listen/@address, running
XML like this:
<graphics type='spice' port='5901' autoport='yes' keymap='en-us'>
<listen type='network' address='192.168.122.1' network='default'/>
</graphics>
This patch will try to get the IP address in this path
/domain/devices/graphics/listen/@address
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
tools/virsh-domain.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 358d61c..4a9b574 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -10024,7 +10024,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
int tmp;
int flags = 0;
bool params = false;
- const char *xpath_fmt = "string(/domain/devices/graphics[@type='%s']/@%s)";
+ const char *xpath_fmt = "string(/domain/devices/graphics[@type='%s']/%s)";
virSocketAddr addr;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
@@ -10054,7 +10054,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
continue;
/* Create our XPATH lookup for the current display's port */
- if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "port") < 0)
+ if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "@port") < 0)
goto cleanup;
/* Attempt to get the port number for the current graphics scheme */
@@ -10068,7 +10068,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
/* Create our XPATH lookup for TLS Port (automatically skipped
* for unsupported schemes */
- if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "tlsPort") < 0)
+ if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "@tlsPort") < 0)
goto cleanup;
/* Attempt to get the TLS port number */
@@ -10081,7 +10081,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
continue;
/* Create our XPATH lookup for the current display's address */
- if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "listen") < 0)
+ if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "listen/@address") < 0)
goto cleanup;
/* Attempt to get the listening addr if set for the current
@@ -10095,7 +10095,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
* care of when getting the XML */
/* Create our XPATH lookup for the password */
- if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "passwd") < 0)
+ if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "@passwd") < 0)
goto cleanup;
/* Attempt to get the password */
--
1.8.3.1
9 years, 9 months
[libvirt] [PATCH v2] qemu: fix setting of VM CPU affinity with TCG
by Daniel P. Berrange
If a previous commit I fixed the incorrect handling of vcpu pids
for TCG mode QEMU:
commit b07f3d821dfb11a118ee75ea275fd6ab737d9500
Author: Daniel P. Berrange <berrange(a)redhat.com>
Date: Thu Dec 18 16:34:39 2014 +0000
Don't setup fake CPU pids for old QEMU
The code assumes that def->vcpus == nvcpupids, so when we setup
fake CPU pids for old QEMU with nvcpupids == 1, we cause the
later code to read off the end of the array. This has fun results
like sche_setaffinity(0, ...) which changes libvirtd's own CPU
affinity, or even better sched_setaffinity($RANDOM, ...) which
changes the affinity of a random OS process.
The intent was that this would merely disable the ability to set
per-vCPU affinity. It should still have been possible to set VM
level host CPU affinity.
Unfortunately, when you set <vcpu cpuset='0-1'>4</vcpu>, the XML
parser will internally take this & initialize an entry in the
def->cputune.vcpupin array for every VCPU. IOW this is implicitly
being treated as
<cputune>
<vcpupin cpuset='0-1' vcpu='0'/>
<vcpupin cpuset='0-1' vcpu='1'/>
<vcpupin cpuset='0-1' vcpu='2'/>
<vcpupin cpuset='0-1' vcpu='3'/>
</cputune>
Even more fun, the faked cputune elements are hidden from view when
querying the live XML, because their cpuset mask is the same as the
VM default cpumask.
The upshot was that it was impossible to set VM level CPU affinity.
To fix this we must update qemuProcessSetVcpuAffinities so that it
only reports a fatal error if the per-VCPU cpu mask is different
from the VM level cpu mask.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_process.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
In v2:
- Check for def->cpumask being NULL
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index d5df60d..4c35f39 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2497,9 +2497,19 @@ qemuProcessSetVcpuAffinities(virDomainObjPtr vm)
return 0;
if (priv->vcpupids == NULL) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("cpu affinity is not supported"));
- return -1;
+ /* If any CPU has custom affinity that differs from the
+ * VM default affinity, we must reject it
+ */
+ for (n = 0; n < def->vcpus; n++) {
+ if (!def->cpumask ||
+ !virBitmapEqual(def->cpumask,
+ def->cputune.vcpupin[n]->cpumask)) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("cpu affinity is not supported"));
+ return -1;
+ }
+ }
+ return 0;
}
for (n = 0; n < def->vcpus; n++) {
--
2.1.0
9 years, 9 months
[libvirt] virsh vcpuinfo with tcg
by Serge Hallyn
Hi,
'virsh vcpuinfo' in 1.2.12 returns an empty line for VMs using tcg. I
assume this is due to commit b07f3d821dfb11 which explicitly sets
nvcpupids to 0 now. Is 'virsh vcpuinfo' returning nothing just an
unfortunate but expected side-effect, or is it a bug and it should
return info anyway? My impression is that qemu_driver.c should be
using vm->def->vcpus rather than priv->nvcpupids to determine the
# of cpus to show?
thanks,
-serge
9 years, 9 months
[libvirt] [PATCH] Fix qemu job handling in SetSchedulerParameters
by Ján Tomko
Commit c5ee5cf added a job to SetSchedulerParameters, but
forgot to change one label in the SCHED_RANGE_CHECK macro.
---
Not yet released.
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 1614340..e3ca437 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -9740,7 +9740,7 @@ qemuSetEmulatorBandwidthLive(virDomainObjPtr vm, virCgroupPtr cgroup,
_("value of '%s' is out of range [%lld, %lld]"), \
NAME, MIN, MAX); \
rc = -1; \
- goto cleanup; \
+ goto endjob; \
}
static int
--
2.0.5
9 years, 9 months
[libvirt] [PATCH 00/12] Implement random number generator hot/cold (un)plug
by Peter Krempa
Extension of Luyao's series with changes that were possible due to the prepare
series for memory hotplug.
Luyao Huang (7):
qemu: Add helper to assign RNG device aliases
qemu: refactor qemuBuildRNGDeviceArgs to allow reuse in RNG hotplug
qemu: command: Make RNG backend device IDs unique
audit: export virDomainAuditRNG
conf: Add helpers to insert/remove/find RNG devices in domain def
qemu: Implement random number generator hotplug
qemu: Implement random number generator hotunplug
Peter Krempa (5):
conf: Introduce helper to find duplicate device address
qemu: command: Shuffle around formatting of alias for RNG device
backend
qemu: command: Break some very long lines in qemuBuildRNGDevStr()
qemu: command: Refactor creation of RNG device commandline
qemu: Implement random number generator cold (un)plug
src/conf/domain_audit.c | 2 +-
src/conf/domain_audit.h | 7 +
src/conf/domain_conf.c | 164 +++++++++++++++++
src/conf/domain_conf.h | 8 +
src/libvirt_private.syms | 6 +
src/qemu/qemu_command.c | 153 +++++++++++----
src/qemu/qemu_command.h | 9 +
src/qemu/qemu_driver.c | 41 ++++-
src/qemu/qemu_hotplug.c | 205 ++++++++++++++++++++-
src/qemu/qemu_hotplug.h | 7 +-
.../qemuxml2argv-aarch64-virt-virtio.args | 4 +-
.../qemuxml2argv-arm-vexpressa9-virtio.args | 4 +-
.../qemuxml2argv-arm-virt-virtio.args | 4 +-
.../qemuxml2argv-s390-piix-controllers.args | 3 +-
.../qemuxml2argv-s390-usb-none.args | 3 +-
.../qemuxml2argv-virtio-rng-ccw.args | 4 +-
.../qemuxml2argv-virtio-rng-default.args | 4 +-
.../qemuxml2argv-virtio-rng-egd.args | 4 +-
.../qemuxml2argv-virtio-rng-multiple.args | 8 +-
.../qemuxml2argv-virtio-rng-random.args | 4 +-
20 files changed, 578 insertions(+), 66 deletions(-)
--
2.2.2
9 years, 9 months
[libvirt] [PATCH] conf: disallow invalid values for video attributes
by Martin Kletzander
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1190956
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/conf/domain_conf.c | 8 ++++----
...v-seclabel-dynamic-none.xml => qemuxml2argv-video-invalid.xml} | 4 +++-
tests/qemuxml2argvtest.c | 1 +
3 files changed, 8 insertions(+), 5 deletions(-)
copy tests/qemuxml2argvdata/{qemuxml2argv-seclabel-dynamic-none.xml => qemuxml2argv-video-invalid.xml} (90%)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d5b15db..77319dc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10580,7 +10580,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
_("ram attribute only supported for type of qxl"));
goto error;
}
- if (virStrToLong_ui(ram, NULL, 10, &def->ram) < 0) {
+ if (virStrToLong_uip(ram, NULL, 10, &def->ram) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("cannot parse video ram '%s'"), ram);
goto error;
@@ -10590,7 +10590,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
}
if (vram) {
- if (virStrToLong_ui(vram, NULL, 10, &def->vram) < 0) {
+ if (virStrToLong_uip(vram, NULL, 10, &def->vram) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("cannot parse video vram '%s'"), vram);
goto error;
@@ -10605,7 +10605,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
_("vgamem attribute only supported for type of qxl"));
goto error;
}
- if (virStrToLong_ui(vgamem, NULL, 10, &def->vgamem) < 0) {
+ if (virStrToLong_uip(vgamem, NULL, 10, &def->vgamem) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("cannot parse video vgamem '%s'"), vgamem);
goto error;
@@ -10613,7 +10613,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
}
if (heads) {
- if (virStrToLong_ui(heads, NULL, 10, &def->heads) < 0) {
+ if (virStrToLong_uip(heads, NULL, 10, &def->heads) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse video heads '%s'"), heads);
goto error;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-none.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-invalid.xml
similarity index 90%
copy from tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-none.xml
copy to tests/qemuxml2argvdata/qemuxml2argv-video-invalid.xml
index cec59f8..e3848e1 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-none.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-invalid.xml
@@ -22,7 +22,9 @@
<controller type='usb' index='0'/>
<controller type='ide' index='0'/>
<controller type='pci' index='0' model='pci-root'/>
+ <video>
+ <model type='qxl' ram='-1' vram='-1' vgamem='-1' heads='-1'/>
+ </video>
<memballoon model='virtio'/>
</devices>
- <seclabel type='none' model='none'/>
</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 77ee630..f864c2a 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1362,6 +1362,7 @@ mymain(void)
QEMU_CAPS_DEVICE_QXL_VGA, QEMU_CAPS_DEVICE_QXL,
QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_QXL_VGA_VGAMEM,
QEMU_CAPS_QXL_VGAMEM);
+ DO_TEST_PARSE_ERROR("video-invalid", NONE);
DO_TEST("virtio-rng-default", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIRTIO_RNG,
QEMU_CAPS_OBJECT_RNG_RANDOM);
--
2.3.0
9 years, 9 months
[libvirt] [PATCH 0/3] attach-interface: Learn net type='direct'
by Michal Privoznik
I've just wanted to hotplug a macvtap device into a running
guest. I was too lazy to write an XML, and I've found out that
virsh attach-interface doesn't know how to plug macvtaps.
Michal Privoznik (3):
virsh attach-interface: Use enum instead of arbitrary integers
virsh: Use VIR_ENUM* macros for vshCmdAttachInterface
virsh attach-interface: Allow macvtap hotplug
tools/virsh-domain.c | 38 ++++++++++++++++++++++++++++----------
tools/virsh.pod | 14 ++++++++------
2 files changed, 36 insertions(+), 16 deletions(-)
--
2.0.5
9 years, 9 months