[libvirt] [PATCH] Fix a memory leak
by Stefan Berger
The below patch fixes the following memory leak.
==20624== 24 bytes in 2 blocks are definitely lost in loss record 532 of
1,867
==20624== at 0x4A05E46: malloc (vg_replace_malloc.c:195)
==20624== by 0x38EC27FC01: strdup (strdup.c:43)
==20624== by 0x4EB6BA3: virDomainChrSourceDefCopy (domain_conf.c:1122)
==20624== by 0x495D76: qemuProcessFindCharDevicePTYs
(qemu_process.c:1497)
==20624== by 0x498321: qemuProcessWaitForMonitor (qemu_process.c:1258)
==20624== by 0x49B5F9: qemuProcessStart (qemu_process.c:3652)
==20624== by 0x468B5C: qemuDomainObjStart (qemu_driver.c:4753)
==20624== by 0x469171: qemuDomainStartWithFlags (qemu_driver.c:4810)
==20624== by 0x4F21735: virDomainCreate (libvirt.c:8153)
==20624== by 0x4302BF: remoteDispatchDomainCreateHelper
(remote_dispatch.h:852)
==20624== by 0x4F72C14: virNetServerProgramDispatch
(virnetserverprogram.c:416)
==20624== by 0x4F6D690: virNetServerHandleJob (virnetserver.c:164)
==20624== by 0x4E8F43D: virThreadPoolWorker (threadpool.c:144)
==20624== by 0x4E8EAB5: virThreadHelper (threads-pthread.c:161)
==20624== by 0x38EC606CCA: start_thread (pthread_create.c:301)
==20624== by 0x38EC2E0C2C: clone (clone.S:115)
---
I am wondering whether 'something' did not work properly before due to
the missing assignment below?
---
src/conf/domain_conf.c | 2 ++
1 file changed, 2 insertions(+)
Index: libvirt-acl/src/conf/domain_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/domain_conf.c
+++ libvirt-acl/src/conf/domain_conf.c
@@ -1174,6 +1174,8 @@ virDomainChrSourceDefCopy(virDomainChrSo
break;
}
+ dest->type = src->type;
+
return 0;
}
12 years, 7 months
[libvirt] [libvirt-glib 1/2] Parse GVirConfigDomainController nodes
by Christophe Fergeau
Update gvir_config_domain_device_new_from_tree to handle
GVirConfigDomainController nodes
---
.../libvirt-gconfig-domain-controller.c | 37 ++++++++++++++++++++
.../libvirt-gconfig-domain-device-private.h | 3 ++
libvirt-gconfig/libvirt-gconfig-domain-device.c | 2 +-
3 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-controller.c b/libvirt-gconfig/libvirt-gconfig-domain-controller.c
index 813c934..2024b54 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-controller.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-controller.c
@@ -49,6 +49,43 @@ static void gvir_config_domain_controller_init(GVirConfigDomainController *contr
controller->priv = GVIR_CONFIG_DOMAIN_CONTROLLER_GET_PRIVATE(controller);
}
+G_GNUC_INTERNAL GVirConfigDomainDevice *
+gvir_config_domain_controller_new_from_tree(GVirConfigXmlDoc *doc,
+ xmlNodePtr tree)
+{
+ const char *type;
+ GType gtype;
+
+ type = gvir_config_xml_get_attribute_content(tree, "type");
+ if (type == NULL)
+ return NULL;
+
+ if (g_str_equal(type, "ide")) {
+ goto unimplemented;
+ } else if (g_str_equal(type, "fdc")) {
+ goto unimplemented;
+ } else if (g_str_equal(type, "scsi")) {
+ goto unimplemented;
+ } else if (g_str_equal(type, "sata")) {
+ goto unimplemented;
+ } else if (g_str_equal(type, "usb")) {
+ gtype = GVIR_CONFIG_TYPE_DOMAIN_CONTROLLER_USB;;
+ } else if (g_str_equal(type, "ccid")) {
+ goto unimplemented;
+ } else if (g_str_equal(type, "virtio-serial")) {
+ goto unimplemented;
+ } else {
+ g_debug("Unknown domain controller node: %s", type);
+ return NULL;
+ }
+
+ return GVIR_CONFIG_DOMAIN_DEVICE(gvir_config_object_new_from_tree(gtype, doc, NULL, tree));
+
+unimplemented:
+ g_debug("Parsing of '%s' domain controller nodes is unimplemented", type);
+ return NULL;
+}
+
void gvir_config_domain_controller_set_index(GVirConfigDomainController *controller,
guint index)
{
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-device-private.h b/libvirt-gconfig/libvirt-gconfig-domain-device-private.h
index 7ba7bc6..f50946a 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-device-private.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain-device-private.h
@@ -31,6 +31,9 @@ GVirConfigDomainDevice *
gvir_config_domain_device_new_from_tree(GVirConfigXmlDoc *doc,
xmlNodePtr tree);
GVirConfigDomainDevice *
+gvir_config_domain_controller_new_from_tree(GVirConfigXmlDoc *doc,
+ xmlNodePtr tree);
+GVirConfigDomainDevice *
gvir_config_domain_disk_new_from_tree(GVirConfigXmlDoc *doc,
xmlNodePtr tree);
GVirConfigDomainDevice *
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-device.c b/libvirt-gconfig/libvirt-gconfig-domain-device.c
index 82e57e9..2f76c8b 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-device.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-device.c
@@ -64,7 +64,7 @@ gvir_config_domain_device_new_from_tree(GVirConfigXmlDoc *doc,
} else if (xmlStrEqual(tree->name, (xmlChar*)"filesystem")) {
type = GVIR_CONFIG_TYPE_DOMAIN_FILESYS;
} else if (xmlStrEqual(tree->name, (xmlChar*)"controller")) {
- goto unimplemented;
+ return gvir_config_domain_controller_new_from_tree(doc, tree);
} else if (xmlStrEqual(tree->name, (xmlChar*)"lease")) {
goto unimplemented;
} else if (xmlStrEqual(tree->name, (xmlChar*)"hostdev")) {
--
1.7.10
12 years, 7 months
[libvirt] [PATCH v2] docs: Improve the schema for fs device
by Osier Yang
<filesystemtgt> is redundant, as every group uses it; <address>
shouldn't be in <filesystemtgt> in case of the meaning could be
"filesystemtarget"; The elements <address>, <alias>, <target>,
... should be interleaved.
---
v1 ~ v2:
No changes
---
docs/schemas/domaincommon.rng | 58 ++++++++++++++++++----------------------
1 files changed, 26 insertions(+), 32 deletions(-)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 0cc04af..f116710 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1210,7 +1210,6 @@
</attribute>
<empty/>
</element>
- <ref name="filesystemtgt"/>
</interleave>
</group>
<group>
@@ -1224,7 +1223,6 @@
</attribute>
<empty/>
</element>
- <ref name="filesystemtgt"/>
</interleave>
</group>
<group>
@@ -1257,7 +1255,6 @@
<empty/>
</element>
</optional>
- <ref name="filesystemtgt"/>
</interleave>
</group>
<group>
@@ -1271,42 +1268,39 @@
</attribute>
<empty/>
</element>
- <ref name="filesystemtgt"/>
</interleave>
</group>
</choice>
- <optional>
- <attribute name="accessmode">
- <choice>
- <value>passthrough</value>
- <value>mapped</value>
- <value>squash</value>
- </choice>
- </attribute>
- </optional>
- <optional>
- <element name='readonly'>
+ <interleave>
+ <element name="target">
+ <attribute name="dir">
+ <ref name="absDirPath"/>
+ </attribute>
<empty/>
</element>
- </optional>
+ <optional>
+ <attribute name="accessmode">
+ <choice>
+ <value>passthrough</value>
+ <value>mapped</value>
+ <value>squash</value>
+ </choice>
+ </attribute>
+ </optional>
+ <optional>
+ <element name='readonly'>
+ <empty/>
+ </element>
+ </optional>
+ <optional>
+ <ref name="alias"/>
+ </optional>
+ <optional>
+ <ref name="address"/>
+ </optional>
+ </interleave>
</element>
</define>
- <define name="filesystemtgt">
- <interleave>
- <optional>
- <ref name="alias"/>
- </optional>
- <optional>
- <ref name="address"/>
- </optional>
- <element name="target">
- <attribute name="dir">
- <ref name="absDirPath"/>
- </attribute>
- <empty/>
- </element>
- </interleave>
- </define>
<!--
An interface description can either be of type bridge in which case
it will use a bridging source, or of type ethernet which uses a device
--
1.7.7.3
12 years, 7 months
[libvirt] [PATCH] libvirt: xen: do not use ioemu type for any emulated NIC
by Stefan Bader
This is a re-send as there was some positive feedback but the
patch itself made it into the repo.
-Stefan
>From a3198c5c1ae8908818f6c0f0df4237dbe5ddeec7 Mon Sep 17 00:00:00 2001
From: Stefan Bader <stefan.bader(a)canonical.com>
Date: Thu, 12 Apr 2012 15:32:41 +0200
Subject: [PATCH] libvirt: xen: do not use ioemu type for any emulated NIC
When using the xm/xend stack to manage instances there is a bug
that causes the emulated interfaces to be unusable when the vif
config contains type=ioemu (MAC address all zero).
The current code already has a special quirk to not use this
keyword if no specific model is given for the emulated NIC
(defaulting to rtl8139).
Essentially it works because regardless of the type argument,
the Xen stack always creates emulated and paravirt interfaces and
lets the guest decide which one to use. So neither xl nor xm stack
actually require the type keyword for emulated NICs.
Signed-off-by: Stefan Bader <stefan.bader(a)canonical.com>
---
src/xenxs/xen_sxpr.c | 4 +++-
src/xenxs/xen_xm.c | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c
index e1bbd76..71602fa 100644
--- a/src/xenxs/xen_sxpr.c
+++ b/src/xenxs/xen_sxpr.c
@@ -2012,7 +2012,9 @@ xenFormatSxprNet(virConnectPtr conn,
}
else {
virBufferEscapeSexpr(buf, "(model '%s')", def->model);
- virBufferAddLit(buf, "(type ioemu)");
+ /* See above. Also needed when model is specified. */
+ if (xendConfigVersion <= XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU)
+ virBufferAddLit(buf, "(type ioemu)");
}
if (!isAttach)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index d65e97a..e072599 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1394,7 +1394,9 @@ static int xenFormatXMNet(virConnectPtr conn,
}
else {
virBufferAsprintf(&buf, ",model=%s", net->model);
- virBufferAddLit(&buf, ",type=ioemu");
+ /* See above. Also needed if model is specified. */
+ if (xendConfigVersion <= XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU)
+ virBufferAddLit(&buf, ",type=ioemu");
}
if (net->ifname)
--
1.7.9.5
12 years, 7 months
[libvirt] "virsh list" hangs
by Qian Zhang
Hi,
I am using RHEL 6.2 64bit, and the libvirt shipped in it is
"libvirt-0.9.4-23.el6.x86_64". I found sometimes the command "virsh
list" hangs forever, and same issue for virt-manager which is always
in "Connecting" status. But after restarting the libvirtd service,
this issue is gone.
Is this a bug of libvirt? Any help will be appreciated.
Thanks,
Qian
12 years, 7 months
Re: [libvirt] [PATCH 7/8] block: add witness argument to drive-reopen
by Eric Blake
[adding libvir-list for some interesting discussions on potential
libvirt design issues]
On 04/17/2012 12:47 AM, Paolo Bonzini wrote:
> Il 16/04/2012 23:55, Eric Blake ha scritto:
>>> Do transient guests have persistent storage for them in /var while they
>>> are running?
>>
>> Yes - that's how libvirt tracks the pid of the qemu process that it
>> should be re-attaching to on a libvirtd restart, as well as several
>> other aspects (for example, the capabilities of the qemu binary running
>> that pid, in case qemu has been upgraded in the meantime). It's just
>> that right now, the files that libvirt stores in /var are intended to be
>> internal to libvirt, so management apps shouldn't be poking around in
>> there, so much as having an interface to ask libvirt what state things
>> are in.
>
> Can libvirtd report the block-job-completed event to vdsm before the
> transient-domain-died event?
Yes, it should be possible to organize the code so that on libvirtd
restart, libvirt is careful to emit all other events, such as block-job
completed/failed, prior to the final domain died event as libvirt cleans
out its records of the dead domain. But it probably involves quite a
bit of code cleanup on libvirt's side to reach that state. There's also
the question of whether vdsm will be listening to the events soon
enough; after all, when libvirtd restarts, libvirt is doing quite a bit
of bookkeeping before even accepting connections, and if vdsm isn't
connected to the restarted libvirt at the time libvirt queues up an
event to be sent, then the event is lost. Maybe that implies that
libvirt needs to have a configurable-depth array of prior events that
can be played back to the user on request.
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
12 years, 7 months
[libvirt] [PATCHv4 00/18] live block migration via virDomainBlockCopy
by Eric Blake
v3 was here:
https://www.redhat.com/archives/libvir-list/2012-April/msg00288.html
changes from v3:
- split v3 patch 8 into 1/18 and 9/18
- incorporate Laine's review comments on v3 patches 1 and 2 (here 2 and 3)
- fix more bugs found during testing
- upgrade to Paolo's latest build (which dropped 'mode':'no-backing-file'
and replaced it with 'full':'true')
- added a new patch 14/18 that lets blockcopy work with SELinux enforcing
(it still leaks files rather than clean up context on job abort or pivot,
but that's a harder problem to solve)
repo.or.cz is acting up on me at the moment, so I won't have a repo
to point to until I can investigate why tomorrow. I'll send an interdiff
in reply to this message.
Adam Litke (2):
blockjob: add API for async virDomainBlockJobAbort
blockjob: wire up qemu async virDomainBlockJobAbort
Eric Blake (16):
blockjob: add qemu capabilities related to block jobs
blockjob: allow for fast-finishing job
blockjob: add new API flags
blockjob: add 'blockcopy' to virsh
blockjob: enhance xml to track mirrors across libvirtd restart
blockjob: react to active block copy
blockjob: expose qemu commands for mirrored storage migration
blockjob: return appropriate event and info
blockjob: support pivot operation on cancel
blockjob: implement block copy for qemu
blockjob: allow for existing files
blockjob: allow mirroring under SELinux
blockjob: accommodate RHEL backport names
blockjob: add virDomainBlockCopy
blockjob: enhance virsh 'blockcopy'
blockjob: wire up qemu and RPC for block copy
docs/apibuild.py | 1 +
docs/formatdomain.html.in | 11 +
docs/schemas/domaincommon.rng | 19 ++-
include/libvirt/libvirt.h.in | 50 +++++-
include/libvirt/virterror.h | 1 +
src/conf/domain_conf.c | 54 ++++++
src/conf/domain_conf.h | 6 +
src/driver.h | 5 +
src/libvirt.c | 223 +++++++++++++++++++++-
src/libvirt_private.syms | 1 +
src/libvirt_public.syms | 5 +
src/qemu/qemu_capabilities.c | 3 +
src/qemu/qemu_capabilities.h | 2 +
src/qemu/qemu_driver.c | 417 +++++++++++++++++++++++++++++++++++++++--
src/qemu/qemu_hotplug.c | 7 +
src/qemu/qemu_monitor.c | 50 +++++
src/qemu/qemu_monitor.h | 18 ++-
src/qemu/qemu_monitor_json.c | 167 ++++++++++++++---
src/qemu/qemu_monitor_json.h | 19 ++-
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 12 +-
src/remote_protocol-structs | 9 +
src/rpc/gendispatch.pl | 1 +
src/util/virterror.c | 6 +
tools/virsh.c | 141 +++++++++++---
tools/virsh.pod | 65 ++++++-
26 files changed, 1195 insertions(+), 99 deletions(-)
--
1.7.7.6
12 years, 7 months
[libvirt] cgroup cpuset limited by default?
by Marc-André Lureau
Hi,
I noticed recently that my system VMs feel much slower, and that seems
to be because of cpuset cgroup which constrain the VM on the first
cpu. This doesn't happen with session VMs, since they are not ruled by
cgroup. I run f17 with libvirt git, the VMs are created with
virt-manager, using mostly default settings
<vcpu>4</vcpu>
<os>
<type arch='x86_64' machine='pc-0.15'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='localtime'/>
Is that intended or is it a bug?
--
Marc-André Lureau
12 years, 7 months
[libvirt] [PATCH v2] qemu: Split ide-drive into ide-cd and ide-hd
by Osier Yang
A "ide-drive" device can be either a hard disk or a CD-ROM,
if there is ",media=cdrom" specified for the backend, it's
a CD-ROM, otherwise it's a hard disk.
Upstream qemu splitted "ide-drive" into "ide-hd" and "ide-cd"
since commit 1f56e32, and ",media=cdrom" is not required for
ide-cd anymore. "ide-drive" is still supported for backwards
compatibility, but no doubt we should go foward.
---
No changes between v1 and v2, just rebasing.
---
src/qemu/qemu_capabilities.c | 3 ++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 25 ++++++++++++++-
tests/qemuhelptest.c | 3 +-
.../qemuxml2argv-disk-ide-drive-split.args | 8 +++++
.../qemuxml2argv-disk-ide-drive-split.xml | 32 ++++++++++++++++++++
tests/qemuxml2argvtest.c | 3 ++
7 files changed, 72 insertions(+), 3 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.xml
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 4e22f3e8..3d1fb43 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -160,6 +160,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
"block-job-sync", /* 90 */
"block-job-async",
"scsi-cd",
+ "ide-cd",
);
struct qemu_feature_flags {
@@ -1454,6 +1455,8 @@ qemuCapsParseDeviceStr(const char *str, virBitmapPtr flags)
qemuCapsSet(flags, QEMU_CAPS_SCSI_BLOCK);
if (strstr(str, "scsi-cd"))
qemuCapsSet(flags, QEMU_CAPS_SCSI_CD);
+ if (strstr(str, "ide-cd"))
+ qemuCapsSet(flags, QEMU_CAPS_IDE_CD);
return 0;
}
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 2aba502..7279cdb 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -127,6 +127,7 @@ enum qemuCapsFlags {
QEMU_CAPS_BLOCKJOB_SYNC = 90, /* RHEL 6.2 block_job_cancel */
QEMU_CAPS_BLOCKJOB_ASYNC = 91, /* qemu 1.1 block-job-cancel */
QEMU_CAPS_SCSI_CD = 92, /* -device scsi-cd */
+ QEMU_CAPS_IDE_CD = 93, /* -device ide-cd */
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 ff82b26..26f691f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1982,6 +1982,9 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
if ((disk->bus == VIR_DOMAIN_DISK_BUS_SCSI)) {
if (!qemuCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD))
virBufferAddLit(&opt, ",media=cdrom");
+ } else if (disk->bus == VIR_DOMAIN_DISK_BUS_IDE) {
+ if (!qemuCapsGet(qemuCaps, QEMU_CAPS_IDE_CD))
+ virBufferAddLit(&opt, ",media=cdrom");
} else {
virBufferAddLit(&opt, ",media=cdrom");
}
@@ -2205,7 +2208,16 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
_("target must be 0 for ide controller"));
goto error;
}
- virBufferAddLit(&opt, "ide-drive");
+
+ if (qemuCapsGet(qemuCaps, QEMU_CAPS_IDE_CD)) {
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
+ virBufferAddLit(&opt, "ide-cd");
+ else
+ virBufferAddLit(&opt, "ide-hd");
+ } else {
+ virBufferAddLit(&opt, "ide-drive");
+ }
+
virBufferAsprintf(&opt, ",bus=ide.%d,unit=%d",
disk->info.addr.drive.bus,
disk->info.addr.drive.unit);
@@ -2301,7 +2313,16 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
_("target must be 0 for ide controller"));
goto error;
}
- virBufferAddLit(&opt, "ide-drive");
+
+ if (qemuCapsGet(qemuCaps, QEMU_CAPS_IDE_CD)) {
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
+ virBufferAddLit(&opt, "ide-cd");
+ else
+ virBufferAddLit(&opt, "ide-hd");
+ } else {
+ virBufferAddLit(&opt, "ide-drive");
+ }
+
virBufferAsprintf(&opt, ",bus=ahci%d.%d",
disk->info.addr.drive.controller,
disk->info.addr.drive.unit);
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index a01c389..d23b35a 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -676,7 +676,8 @@ mymain(void)
QEMU_CAPS_CPU_HOST,
QEMU_CAPS_FSDEV_WRITEOUT,
QEMU_CAPS_SCSI_BLOCK,
- QEMU_CAPS_SCSI_CD);
+ QEMU_CAPS_SCSI_CD,
+ QEMU_CAPS_IDE_CD);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.args
new file mode 100644
index 0000000..e24490d
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.args
@@ -0,0 +1,8 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
+/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
+-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-1 \
+-device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
+-drive file=/tmp/idedisk.img,if=none,id=drive-ide0-0-2 \
+-device ide-hd,bus=ide.0,unit=2,drive=drive-ide0-0-2,id=ide0-0-2 \
+-usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.xml
new file mode 100644
index 0000000..b965677
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.xml
@@ -0,0 +1,32 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu>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>
+ <disk type='block' device='cdrom'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='1'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <source file='/tmp/idedisk.img'/>
+ <target dev='hdc' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='2'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='ide' index='1'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index cc1ac44..ee7a8e1 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -758,6 +758,9 @@ mymain(void)
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST("pseries-vio-address-clash", true, QEMU_CAPS_DRIVE,
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
+ DO_TEST("disk-ide-drive-split", false,
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
+ QEMU_CAPS_IDE_CD);
VIR_FREE(driver.stateDir);
virCapabilitiesFree(driver.caps);
--
1.7.7.3
12 years, 7 months
[libvirt] [PATCH v2] qemu: Split scsi-disk into into scsi-hd and scsi-cd
by Osier Yang
A "scsi-disk" device can be either a hard disk or a CD-ROM,
if there is ",media=cdrom" specified for the backend, it's
a CD-ROM, otherwise it's a hard disk.
But upstream qemu splitted "scsi-disk" into "scsi-hd" and
"scsi-cd" since commit b443ae, and ",media=cdrom" is not
required for scsi-cd anymore. "scsi-disk" is still supported
for backwards compatibility, but no doubt we should go
foward.
---
No changes since v1
---
src/qemu/qemu_capabilities.c | 3 +++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 39 +++++++++++++++++++++++++++++++--------
tests/qemuhelptest.c | 6 ++++--
tests/qemuxml2argvtest.c | 3 +++
5 files changed, 42 insertions(+), 10 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index fd4ca4d..4e22f3e8 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -159,6 +159,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
"block-job-sync", /* 90 */
"block-job-async",
+ "scsi-cd",
);
struct qemu_feature_flags {
@@ -1451,6 +1452,8 @@ qemuCapsParseDeviceStr(const char *str, virBitmapPtr flags)
qemuCapsSet(flags, QEMU_CAPS_SCSI_DISK_CHANNEL);
if (strstr(str, "scsi-block"))
qemuCapsSet(flags, QEMU_CAPS_SCSI_BLOCK);
+ if (strstr(str, "scsi-cd"))
+ qemuCapsSet(flags, QEMU_CAPS_SCSI_CD);
return 0;
}
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 6550d59..2aba502 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -126,6 +126,7 @@ enum qemuCapsFlags {
QEMU_CAPS_TRANSACTION = 89, /* transaction monitor command */
QEMU_CAPS_BLOCKJOB_SYNC = 90, /* RHEL 6.2 block_job_cancel */
QEMU_CAPS_BLOCKJOB_ASYNC = 91, /* qemu 1.1 block-job-cancel */
+ QEMU_CAPS_SCSI_CD = 92, /* -device scsi-cd */
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 c82f5bc..ff82b26 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1978,8 +1978,14 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
else
virBufferAsprintf(&opt, "if=%s", bus);
- if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
- virBufferAddLit(&opt, ",media=cdrom");
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
+ if ((disk->bus == VIR_DOMAIN_DISK_BUS_SCSI)) {
+ if (!qemuCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD))
+ virBufferAddLit(&opt, ",media=cdrom");
+ } else {
+ virBufferAddLit(&opt, ",media=cdrom");
+ }
+ }
if (qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
virBufferAsprintf(&opt, ",id=%s%s", QEMU_DRIVE_HOST_PREFIX, disk->info.alias);
@@ -2229,10 +2235,19 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
goto error;
}
- if (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN)
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
virBufferAddLit(&opt, "scsi-block");
- else
- virBufferAddLit(&opt, "scsi-disk");
+ } else {
+ if (qemuCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD)) {
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
+ virBufferAddLit(&opt, "scsi-cd");
+ else
+ virBufferAddLit(&opt, "scsi-hd");
+ } else {
+ virBufferAddLit(&opt, "scsi-disk");
+ }
+ }
+
virBufferAsprintf(&opt, ",bus=scsi%d.%d,scsi-id=%d",
disk->info.addr.drive.controller,
disk->info.addr.drive.bus,
@@ -2255,10 +2270,18 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
}
}
- if (disk->device != VIR_DOMAIN_DISK_DEVICE_LUN)
- virBufferAddLit(&opt, "scsi-disk");
- else
+ if (disk->device != VIR_DOMAIN_DISK_DEVICE_LUN) {
+ if (qemuCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD)) {
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
+ virBufferAddLit(&opt, "scsi-cd");
+ else
+ virBufferAddLit(&opt, "scsi-hd");
+ } else {
+ virBufferAddLit(&opt, "scsi-disk");
+ }
+ } else {
virBufferAddLit(&opt, "scsi-block");
+ }
virBufferAsprintf(&opt, ",bus=scsi%d.0,channel=%d,scsi-id=%d,lun=%d",
disk->info.addr.drive.controller,
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index 05fdc4d..a01c389 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -605,7 +605,8 @@ mymain(void)
QEMU_CAPS_VIRTIO_BLK_SCSI,
QEMU_CAPS_VIRTIO_BLK_SG_IO,
QEMU_CAPS_DRIVE_COPY_ON_READ,
- QEMU_CAPS_CPU_HOST);
+ QEMU_CAPS_CPU_HOST,
+ QEMU_CAPS_SCSI_CD);
DO_TEST("qemu-1.0", 1000000, 0, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -674,7 +675,8 @@ mymain(void)
QEMU_CAPS_VIRTIO_BLK_SG_IO,
QEMU_CAPS_CPU_HOST,
QEMU_CAPS_FSDEV_WRITEOUT,
- QEMU_CAPS_SCSI_BLOCK);
+ QEMU_CAPS_SCSI_BLOCK,
+ QEMU_CAPS_SCSI_CD);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index fdbe95a..cc1ac44 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -463,6 +463,9 @@ mymain(void)
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST("disk-scsi-device-auto", false,
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
+ DO_TEST("disk-scsi-disk-split", false,
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
+ QEMU_CAPS_SCSI_CD);
DO_TEST("disk-scsi-vscsi", false,
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST("disk-scsi-virtio-scsi", false,
--
1.7.7.3
12 years, 7 months