[libvirt] [PATCH] Refactor loop device setup code in LXC
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Minor re-factoring of code for setting up loop devices in
the LXC controller
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/lxc/lxc_controller.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 78e8a70..a7e715e 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -383,12 +383,13 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl)
int ret = -1;
for (i = 0 ; i < ctrl->def->nfss ; i++) {
+ virDomainFSDefPtr fs = ctrl->def->fss[i];
int fd;
- if (ctrl->def->fss[i]->type != VIR_DOMAIN_FS_TYPE_FILE)
+ if (fs->type != VIR_DOMAIN_FS_TYPE_FILE)
continue;
- fd = virLXCControllerSetupLoopDevice(ctrl->def->fss[i]);
+ fd = virLXCControllerSetupLoopDevice(fs);
if (fd < 0)
goto cleanup;
--
1.7.11.7
11 years, 7 months
[libvirt] [PATCH] Fix crash parsing RNG device specification
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Code that validates the whitelist for the RNG device filename
didn't account for fact that filename may be NULL. This led
to a NULL reference crash. This wasn't caught since the test
suite was not covering this XML syntax
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/conf/domain_conf.c | 3 ++-
.../qemuxml2argv-virtio-rng-default.args | 6 ++++++
.../qemuxml2argv-virtio-rng-default.xml | 23 ++++++++++++++++++++++
tests/qemuxml2argvtest.c | 2 ++
4 files changed, 33 insertions(+), 1 deletion(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.xml
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f7c8af1..3c4e043 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7424,7 +7424,8 @@ virDomainRNGDefParseXML(const xmlNodePtr node,
switch ((enum virDomainRNGBackend) def->backend) {
case VIR_DOMAIN_RNG_BACKEND_RANDOM:
def->source.file = virXPathString("string(./backend)", ctxt);
- if (STRNEQ(def->source.file, "/dev/random") &&
+ if (def->source.file &&
+ STRNEQ(def->source.file, "/dev/random") &&
STRNEQ(def->source.file, "/dev/hwrng")) {
virReportError(VIR_ERR_XML_ERROR,
_("file '%s' is not a supported random source"),
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.args b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.args
new file mode 100644
index 0000000..a5f04fd
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.args
@@ -0,0 +1,6 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu \
+-S -M pc -m 214 -smp 1 -nographic -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \
+-object rng-random,id=rng0 \
+-device virtio-rng-pci,rng=rng0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.xml
new file mode 100644
index 0000000..0852dea
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.xml
@@ -0,0 +1,23 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <controller type='usb' index='0'/>
+ <memballoon model='virtio'/>
+ <rng model='virtio'>
+ <backend model='random'/>
+ </rng>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index b6b5489..2354733 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -882,6 +882,8 @@ mymain(void)
QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_QXL_VGA);
+ DO_TEST("virtio-rng-default", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIRTIO_RNG,
+ QEMU_CAPS_OBJECT_RNG_RANDOM);
DO_TEST("virtio-rng-random", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIRTIO_RNG,
QEMU_CAPS_OBJECT_RNG_RANDOM);
DO_TEST("virtio-rng-egd", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIRTIO_RNG,
--
1.7.11.7
11 years, 7 months
[libvirt] [PATCHv3] qdev: DEVICE_DELETED event
by Michael S. Tsirkin
libvirt has a long-standing bug: when removing the device,
it can request removal but does not know when the
removal completes. Add an event so we can fix this in a robust way.
Signed-off-by: Michael S. Tsirkin <mst(a)redhat.com>
---
Changes from v2:
- move event toward the end of device_unparent,
so that parents are reported after their children,
as suggested by Paolo
Changes from v1:
- move to device_unparent
- address comments by Andreas and Eric
QMP/qmp-events.txt | 15 +++++++++++++++
hw/qdev.c | 6 ++++++
include/monitor/monitor.h | 1 +
monitor.c | 1 +
qapi-schema.json | 4 +++-
5 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt
index b2698e4..f2f115a 100644
--- a/QMP/qmp-events.txt
+++ b/QMP/qmp-events.txt
@@ -136,6 +136,21 @@ Example:
Note: The "ready to complete" status is always reset by a BLOCK_JOB_ERROR
event.
+DEVICE_DELETED
+-----------------
+
+Emitted whenever the device removal completion is acknowledged
+by the guest. At this point, it's safe to reuse the specified device ID.
+Device removal can be initiated by the guest or by HMP/QMP commands.
+
+Data:
+
+- "device": device name (json-string)
+
+{ "event": "DEVICE_DELETED",
+ "data": { "device": "virtio-net-pci-0" },
+ "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
+
DEVICE_TRAY_MOVED
-----------------
diff --git a/hw/qdev.c b/hw/qdev.c
index 689cd54..393e83e 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -29,6 +29,7 @@
#include "sysemu/sysemu.h"
#include "qapi/error.h"
#include "qapi/visitor.h"
+#include "qapi/qmp/qjson.h"
int qdev_hotplug = 0;
static bool qdev_hot_added = false;
@@ -778,6 +779,11 @@ static void device_unparent(Object *obj)
object_unref(OBJECT(dev->parent_bus));
dev->parent_bus = NULL;
}
+ if (dev->id) {
+ QObject *data = qobject_from_jsonf("{ 'device': %s }", dev->id);
+ monitor_protocol_event(QEVENT_DEVICE_DELETED, data);
+ qobject_decref(data);
+ }
}
static void device_class_init(ObjectClass *class, void *data)
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index 87fb49c..b868760 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -39,6 +39,7 @@ typedef enum MonitorEvent {
QEVENT_BLOCK_JOB_CANCELLED,
QEVENT_BLOCK_JOB_ERROR,
QEVENT_BLOCK_JOB_READY,
+ QEVENT_DEVICE_DELETED,
QEVENT_DEVICE_TRAY_MOVED,
QEVENT_SUSPEND,
QEVENT_SUSPEND_DISK,
diff --git a/monitor.c b/monitor.c
index 32a6e74..2a5e7b6 100644
--- a/monitor.c
+++ b/monitor.c
@@ -457,6 +457,7 @@ static const char *monitor_event_names[] = {
[QEVENT_BLOCK_JOB_CANCELLED] = "BLOCK_JOB_CANCELLED",
[QEVENT_BLOCK_JOB_ERROR] = "BLOCK_JOB_ERROR",
[QEVENT_BLOCK_JOB_READY] = "BLOCK_JOB_READY",
+ [QEVENT_DEVICE_DELETED] = "DEVICE_DELETED",
[QEVENT_DEVICE_TRAY_MOVED] = "DEVICE_TRAY_MOVED",
[QEVENT_SUSPEND] = "SUSPEND",
[QEVENT_SUSPEND_DISK] = "SUSPEND_DISK",
diff --git a/qapi-schema.json b/qapi-schema.json
index 28b070f..bb361e1 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2354,7 +2354,9 @@
# Notes: When this command completes, the device may not be removed from the
# guest. Hot removal is an operation that requires guest cooperation.
# This command merely requests that the guest begin the hot removal
-# process.
+# process. Completion of the device removal process is signaled with a
+# DEVICE_DELETED event. Guest reset will automatically complete removal
+# for all devices.
#
# Since: 0.14.0
##
--
MST
11 years, 7 months
Re: [libvirt] [PATCH] qdev: DEVICE_DELETED event
by Eric Blake
[adding libvirt]
On 03/06/2013 07:52 AM, Paolo Bonzini wrote:
> Il 06/03/2013 15:44, Eric Blake ha scritto:
>> Question - if libvirt misses the event (for example, if libvirtd
>> requests a remove, but then gets restarted, and the event arrives before
>> libvirtd is back up), is there a way to poll whether the the removal has
>> completed? The event is great to minimize polling overhead in the
>> common case, but we generally provide this sort of information via a
>> pollable interface at the same time.
>
> Yes, you can use qom-list on /machine/peripheral.
Which means libvirt should be patched to use qom-list right now, even
before this event makes it in, in order to avoid its current bug of
reusing a device id before the deletion has completed. Adding the event
is still useful, as polling is never nice; and we already know how to
make libvirt do conditional code based on whether query-events shows
that the event has been added to minimize polling where possible.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
11 years, 7 months
[libvirt] virsh qemu+tls login error
by yue
hi all
on client side , (cacert.pem,clientcert.pem,clientkey.pem) certificate are in position. spicec can connect server(kvm host) successfully.
'virsh -c qemu+tcp ' can work well.
but virsh command line error when launch virsh -c qemu+tls..............
[root@ovirtdev libvirt]# virsh -d 0 -c qemu+tls://192.168.5.113/system hostname
commands: "hostname"
2013-03-06 07:05:22.716+0000: 22245: info : libvirt version: 0.9.10, package: 21.el6_3.8 (CentOS BuildSystem <http://bugs.centos.org>, 2013-01-28-19:24:16, c6b10.bsys.dev.centos.org)
2013-03-06 07:05:22.716+0000: 22245: warning : virNetTLSContextCheckCertificate:1093 : Certificate check failed Certificate failed validation: The certificate hasn't got a known issuer.
error: authentication failed: Failed to verify peer's certificate
error: failed to connect to the hypervisor
[root@ovirtdev libvirt]#
11 years, 8 months
[libvirt] Cannot download gnulib
by harryxiyou
Hi all,
When i wanna install libvirt, i happened to following errors.
$./autogen.sh
I am going to run ./configure with no arguments - if you wish
to pass any to it, please specify them on the ./autogen.sh command line.
running bootstrap...
./bootstrap: Bootstrapping from checked-out http://libvirt.org sources...
./bootstrap: consider installing git-merge-changelog from gnulib
./bootstrap: getting gnulib files...
Submodule 'gnulib' () registered for path '.gnulib'
fatal: Needed a single revision
Unable to find current revision in submodule path '.gnulib'
Failed to bootstrap, please investigate.
Could anyone give me some suggestions? Thanks in advance ;-)
--
Thanks
Harry Wei
11 years, 8 months
[libvirt] [PATCH] Resolve valgrind error
by John Ferlan
Resolves the following valgrind error from qemuxml2argvtest:
==20393== 5 bytes in 1 blocks are definitely lost in loss record 2 of 60
==20393== at 0x4A0883C: malloc (vg_replace_malloc.c:270)
==20393== by 0x38D690A167: __vasprintf_chk (in /usr/lib64/libc-2.16.so)
==20393== by 0x4CB0D97: virVasprintf (stdio2.h:210)
==20393== by 0x4CB0E53: virAsprintf (virutil.c:2017)
==20393== by 0x428DC5: qemuAssignDeviceAliases (qemu_command.c:791)
==20393== by 0x41DF93: testCompareXMLToArgvHelper (qemuxml2argvtest.c:151)
==20393== by 0x41F53F: virtTestRun (testutils.c:157)
==20393== by 0x41DA9B: mymain (qemuxml2argvtest.c:885)
==20393== by 0x41FB7A: virtTestMain (testutils.c:719)
==20393== by 0x38D6821A04: (below main) (in /usr/lib64/libc-2.16.so)
==20393==
>From qemu_command.c/line 791:
if (def->rng) {
if (virAsprintf(&def->rng->info.alias, "rng%d", 0) < 0)
goto no_memory;
}
---
src/conf/domain_conf.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f7c8af1..739bd72 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13760,6 +13760,7 @@ virDomainRNGDefFree(virDomainRNGDefPtr def)
break;
}
+ virDomainDeviceInfoClear(&def->info);
VIR_FREE(def);
}
--
1.8.1.2
11 years, 8 months
[libvirt] [PATCH] rng: restrict passthrough names to known-good files
by Eric Blake
There is some controversy[1] on the qemu list on whether qemu should
have ever allowed arbitrary file name passthrough, or whether it
should be restricted to JUST /dev/random and /dev/hwrng. It is
always easier to add support for additional filenames than it is
to remove support for something once released, so this patch
restricts libvirt 1.0.3 (where the virtio-random backend was first
supported) to just the two uncontroversial names, letting us defer
to a later date any decision on whether supporting arbitrary files
makes sense. Additionally, since qemu 1.4 does NOT support
/dev/fdset/nnn fd passthrough for the backend, limiting to just
two known names means that we don't get tempted to try fd
passthrough where it won't work.
[1]https://lists.gnu.org/archive/html/qemu-devel/2013-03/threads.html#00023
* src/conf/domain_conf.c (virDomainRNGDefParseXML): Only allow
/dev/random and /dev/hwrng.
* docs/schemas/domaincommon.rng: Flag invalid files.
* docs/formatdomain.html.in (elementsRng): Document this.
* tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.args:
Update test to match.
* tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.xml:
Likewise.
---
This needs to be acked before libvirt 1.0.3; otherwise we are
stuck supporting arbitrary name passthrough.
docs/formatdomain.html.in | 3 ++-
docs/schemas/domaincommon.rng | 5 ++++-
src/conf/domain_conf.c | 7 +++++++
tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.args | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.xml | 2 +-
5 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 1835b39..4cafc92 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4310,7 +4310,8 @@ qemu-kvm -net nic,model=? /dev/null
<code>model</code> attribute. Supported source models are:
</p>
<ul>
- <li>'random' — /dev/random (default) or similar device as source</li>
+ <li>'random' — /dev/random (default) or /dev/hwrng
+ device as source (for now, no other sources are permitted)</li>
<li>'egd' — a EGD protocol backend</li>
</ul>
</dd>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index e7231cc..4b60885 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3511,7 +3511,10 @@
<attribute name="model">
<value>random</value>
</attribute>
- <ref name="filePath"/>
+ <choice>
+ <value>/dev/random</value>
+ <value>/dev/hwrng</value>
+ </choice>
</group>
<group>
<attribute name="model">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 995cf0c..9c96cf1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7423,6 +7423,13 @@ virDomainRNGDefParseXML(const xmlNodePtr node,
switch ((enum virDomainRNGBackend) def->backend) {
case VIR_DOMAIN_RNG_BACKEND_RANDOM:
def->source.file = virXPathString("string(./backend)", ctxt);
+ if (STRNEQ(def->source.file, "/dev/random") &&
+ STRNEQ(def->source.file, "/dev/hwrng")) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("file '%s' is not a supported random source"),
+ def->source.file);
+ goto error;
+ }
break;
case VIR_DOMAIN_RNG_BACKEND_EGD:
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.args b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.args
index ad27132..7ab9dbc 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.args
@@ -2,5 +2,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu \
-S -M pc -m 214 -smp 1 -nographic -nodefaults \
-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \
--object 'rng-random,id=rng0,filename=/test/ph<ile' \
+-object rng-random,id=rng0,filename=/dev/hwrng \
-device virtio-rng-pci,rng=rng0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.xml
index 0658f4b..1e2c4be 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.xml
@@ -17,7 +17,7 @@
<controller type='usb' index='0'/>
<memballoon model='virtio'/>
<rng model='virtio'>
- <backend model='random'>/test/ph<ile</backend>
+ <backend model='random'>/dev/hwrng</backend>
</rng>
</devices>
</domain>
--
1.8.1.4
11 years, 8 months