[libvirt] Interface XML description
by arnaud.champion@devatom.fr
?Hi,
I'm currently working on C# binding, precisly on virInterface things. I don't see any XML documentation around interface XML description. IS there infos anywhere ?
Regards,
Arnaud
13 years, 10 months
[libvirt] [PATCH 1/3] cgroup: Enable cgroup hierarchy for blkio cgroup
by Gui Jianfeng
Enable cgroup hierarchy for blkio cgroup.
Signed-off-by: Gui Jianfeng <guijianfen(a)cn.fujitsu.com>
---
src/util/cgroup.c | 2 +-
src/util/cgroup.h | 1 +
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index cd9caba..309f4e9 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -37,7 +37,7 @@
VIR_ENUM_IMPL(virCgroupController, VIR_CGROUP_CONTROLLER_LAST,
"cpu", "cpuacct", "cpuset", "memory", "devices",
- "freezer");
+ "freezer", "blkio");
struct virCgroupController {
int type;
diff --git a/src/util/cgroup.h b/src/util/cgroup.h
index 964da7a..67b1299 100644
--- a/src/util/cgroup.h
+++ b/src/util/cgroup.h
@@ -22,6 +22,7 @@ enum {
VIR_CGROUP_CONTROLLER_MEMORY,
VIR_CGROUP_CONTROLLER_DEVICES,
VIR_CGROUP_CONTROLLER_FREEZER,
+ VIR_CGROUP_CONTROLLER_BLKIO,
VIR_CGROUP_CONTROLLER_LAST
};
--
1.7.1
13 years, 10 months
[libvirt] Move "Bindings" page under "Downloads" heading?
by Justin Clift
Hi us,
It just clicked for me, that when people want to download (or even find) our
language bindings, they have to find them through our Documentation section
pages.
Would it make more sense to have our language bindings listed under Downloads?
+ Justin
13 years, 10 months
[libvirt] [PATCH] qemu: Error prompt when managed save a shutoff domain
by Osier Yang
The problem was intrduced by commit 4303c91, which removed the checking
of domain state, this patch is to fix it.
Otherwise, improper error will be throwed, e.g.
# virsh managedsave rhel6
error: Failed to save domain rhel6 state
error: cannot resolve symlink /var/lib/libvirt/qemu/save/rhel6.save: No such
file or directory
---
src/qemu/qemu_driver.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 34cc29f..575dbd3 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4640,6 +4640,12 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
goto cleanup;
}
+ if (!virDomainObjIsActive(vm)) {
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto cleanup;
+ }
+
name = qemuDomainManagedSavePath(driver, vm);
if (name == NULL)
goto cleanup;
--
1.7.3.2
13 years, 10 months
[libvirt] Rudimentary (basic) s390x architecture functions for libvirt
by Patrick Siegl
Hello there,
I don't know whether or not you are only interested in the x86 / x86_64
architecture, but I think you could also be interested in the small bit
of code which I have programmed. Since the release of libvirt 0.8.5,
there is a small bit of s390x architecture code (one line) within
libvirt which has given me the impression that you could be interested
in my small bit of code.
I study 'computer science' at the University of Tuebingen (Germany) and
each student has to do a research study during his studies on his way to
receiving his diploma.
One of my goals is to implement basic s390x functions into libvirt in
order to be able to start / create virtual machines on a s390x
architecture (i.e. on our IBM Mainframe z9 at the university) more easily.
Our Setup is (as just mentioned) an IBM Mainframe z9 on which I have the
root access to a zLinux (which runs native on two LPARs) with the OS
"SUSE Enterprise 11 SP1" and a kernel 2.6.34. (Our test virtual machine
is a copy of the running zLinux.)
I have actually implemented my patch into libvirt release 0.8.6 but I
think a git patch would be more practical for you, so I have implemented
it into git today (see underneath or attachment). The following XML file
creates a virtual machine on my zLinux with my git patch which is listed
underneath (or attachment).
As you can see, there is not much that needs to be done so that libvirt
can create rudimentary virtual machines on IBM Mainframe z9 (under an
zLinux).
Regards,
Patrick Siegl
University of Tuebingen (Germany)
Here is the necessary XML file:
===============================================================
<domain type='kvm'>
<name>TestVM</name>
<uuid></uuid>
<memory>1024000</memory>
<currentMemory>1024000</currentMemory>
<cpu>
<topology sockets='1' cores='1' threads='1'/>
</cpu>
<os>
<type arch="s390x" machine='s390'>hvm</type>
<kernel>/boot/image-2.6.34-tue01</kernel>
<initrd>/boot/initrd-2.6.34-tue01_GUEST</initrd>
<cmdline>"root=/dev/vda1 rw"</cmdline>
<boot dev='hd'/>
</os>
<devices>
<graphics type='vnc' port='5903' listen='' keymap='de'/>
<console type='vc'>
<target type='virtio' name='virtio.serial'/>
</console>
<disk type='file' device='disk'>
<source file='/data/sle11.img'/>
<target dev='vda'/>
</disk>
<interface type='ethernet'>
<target dev='tap0'/>
<mac address='00:17:31:88:AC:86'/>
<ip address='134.2.14.241'/>
</interface>
</devices>
</domain>
... and here is the patch:
===============================================================
diff --git a/libvirt-git/src/qemu/qemu_capabilities.c
b/libvirt/src/qemu/qemu_capabilities.c
index faf7d44..7bbb1d5 100644
--- a/libvirt-git/src/qemu/qemu_capabilities.c
+++ b/libvirt/src/qemu/qemu_capabilities.c
@@ -83,7 +83,7 @@ static const struct qemu_arch_info const
arch_info_hvm[] = {
{ "sparc", 32, NULL, "qemu-system-sparc", NULL, NULL, 0 },
{ "ppc", 32, NULL, "qemu-system-ppc", NULL, NULL, 0 },
{ "itanium", 64, NULL, "qemu-system-ia64", NULL, NULL, 0 },
- { "s390x", 64, NULL, "qemu-system-s390x", NULL, NULL, 0 },
+ { "s390x", 64, NULL, "qemu-system-s390x", NULL, NULL, 0 }, //
Since 0.8.5: doesn't work on it's own!
};
static const struct qemu_arch_info const arch_info_xen[] = {
diff --git a/libvirt-git/src/nodeinfo.c b/libvirt/src/nodeinfo.c
index 22d53e5..c9059d4 100644
--- a/libvirt-git/src/nodeinfo.c
+++ b/libvirt/src/nodeinfo.c
@@ -164,7 +164,11 @@ cleanup:
static int parse_socket(unsigned int cpu)
{
+# if ( defined __s390x__ || defined __s390__ )
+ return 0; /* s390 does not implement physical_package_id by now */
+# else
return get_cpu_value(cpu, "topology/physical_package_id", false);
+# endif
}
int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
@@ -195,6 +199,30 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
* has no knowledge of NUMA nodes */
/* NOTE: hyperthreads are ignored here; they are parsed out of /sys */
+# if defined __s390x__ || defined __s390__
+ while (fgets(line, sizeof(line), cpuinfo) != NULL) {
+ char *buf = line;
+ if (STRPREFIX(buf, "# processors")) { /* Number of processors */
+ char *p;
+ unsigned int id;
+ buf += 12;
+ while (*buf && c_isspace(*buf))
+ buf++;
+ if (*buf != ':' || !buf[1]) {
+ nodeReportError(VIR_ERR_INTERNAL_ERROR,
+ "parsing cpuinfo cpu count %c", *buf);
+ return -1;
+ }
+ if (virStrToLong_ui(buf+1, &p, 10, &id) == 0
+ && (*p == '\0' || c_isspace(*p))
+ && id > nodeinfo->cores) {
+ nodeinfo->cpus = id;
+ nodeinfo->cores = 1;
+ nodeinfo->mhz = 1400; /* z9 BC */
+ }
+ }
+ }
+# else /* no s390 */
while (fgets(line, sizeof(line), cpuinfo) != NULL) {
char *buf = line;
if (STRPREFIX(buf, "processor")) { /* aka a single logical CPU */
@@ -239,6 +267,7 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
nodeinfo->cores = id;
}
}
+# endif /* s390 */
if (!nodeinfo->cpus) {
nodeReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/libvirt-git/src/qemu/qemu_command.c
b/libvirt/src/qemu/qemu_command.c
index c20f031..0419a0c 100644
--- a/libvirt-git/src/qemu/qemu_command.c
+++ b/libvirt/src/qemu/qemu_command.c
@@ -1267,9 +1267,15 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
break;
}
} else {
+# if ( defined __s390x__ || defined __s390__ )
+ virBufferVSprintf(&opt, "file=%s", disk->src);
+# else
virBufferVSprintf(&opt, "file=%s,", disk->src);
+# endif
}
}
+// makes problems under s390x
+# if ! ( defined __s390x__ || defined __s390__ )
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)
virBufferAddLit(&opt, "if=none");
else
@@ -1291,6 +1297,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
virBufferVSprintf(&opt, ",unit=%d", unitid);
}
}
+# endif
if (bootable &&
disk->device == VIR_DOMAIN_DISK_DEVICE_DISK &&
disk->bus != VIR_DOMAIN_DISK_BUS_IDE)
@@ -1298,10 +1305,12 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
if (disk->readonly &&
qemuCmdFlags & QEMUD_CMD_FLAG_DRIVE_READONLY)
virBufferAddLit(&opt, ",readonly=on");
+# if ! ( defined __s390x__ || defined __s390__ )
if (disk->driverType && *disk->driverType != '\0' &&
disk->type != VIR_DOMAIN_DISK_TYPE_DIR &&
qemuCmdFlags & QEMUD_CMD_FLAG_DRIVE_FORMAT)
virBufferVSprintf(&opt, ",format=%s", disk->driverType);
+# endif
if (disk->serial &&
(qemuCmdFlags & QEMUD_CMD_FLAG_DRIVE_SERIAL)) {
if (qemuSafeSerialParamValue(disk->serial) < 0)
@@ -1370,8 +1379,12 @@ qemuBuildDriveDevStr(virDomainDiskDefPtr disk,
disk->info.addr.drive.unit);
break;
case VIR_DOMAIN_DISK_BUS_VIRTIO:
+# if ( defined __s390x__ || defined __s390__ )
+ virBufferAddLit(&opt, "virtio-blk-s390");
+# else
virBufferAddLit(&opt, "virtio-blk-pci");
qemuBuildDeviceAddressStr(&opt, &disk->info);
+# endif
break;
case VIR_DOMAIN_DISK_BUS_USB:
virBufferAddLit(&opt, "usb-storage");
@@ -1476,6 +1489,9 @@
qemuBuildControllerDevStr(virDomainControllerDefPtr def)
break;
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
+# if ( defined __s390x__ || defined __s390__ )
+ virBufferAddLit(&buf, "virtio-serial-s390");
+# else
if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
virBufferAddLit(&buf, "virtio-serial-pci");
} else {
@@ -1491,6 +1507,7 @@
qemuBuildControllerDevStr(virDomainControllerDefPtr def)
virBufferVSprintf(&buf, ",vectors=%d",
def->opts.vioserial.vectors);
}
+# endif
break;
/* We always get an IDE controller, whether we want it or not. */
@@ -1499,6 +1516,7 @@
qemuBuildControllerDevStr(virDomainControllerDefPtr def)
goto error;
}
+# if ! ( defined __s390x__ || defined __s390__ )
if (qemuBuildDeviceAddressStr(&buf, &def->info) < 0)
goto error;
@@ -1506,6 +1524,7 @@
qemuBuildControllerDevStr(virDomainControllerDefPtr def)
virReportOOMError();
goto error;
}
+# endif
return virBufferContentAndReset(&buf);
@@ -1551,7 +1570,11 @@ qemuBuildNicDevStr(virDomainNetDefPtr net,
if (!net->model) {
nic = "rtl8139";
} else if (STREQ(net->model, "virtio")) {
+# if ( defined __s390x__ || defined __s390__ )
+ nic = "virtio-net-s390";
+# else
nic = "virtio-net-pci";
+# endif
} else {
nic = net->model;
}
@@ -2587,7 +2610,11 @@ qemuBuildCommandLine(virConnectPtr conn,
break;
}
- cmd = virCommandNewArgList(emulator, "-S", NULL);
+# if ! ( defined __s390x__ || defined __s390__ )
+ cmd = virCommandNewArgList(emulator, "-S", NULL); // param '-S'
makes problems under s390x
+# else
+ cmd = virCommandNewArgList(emulator, "", NULL);
+# endif
virCommandAddEnvPassCommon(cmd);
@@ -2909,8 +2936,10 @@ qemuBuildCommandLine(virConnectPtr conn,
def->onReboot != VIR_DOMAIN_LIFECYCLE_RESTART)
virCommandAddArg(cmd, "-no-reboot");
+# if ! ( defined __s390x__ || defined __s390__ )
if (!(def->features & (1 << VIR_DOMAIN_FEATURE_ACPI)))
virCommandAddArg(cmd, "-no-acpi");
+# endif
if (!def->os.bootloader) {
for (i = 0 ; i < def->os.nBootDevs ; i++) {
@@ -2980,6 +3009,7 @@ qemuBuildCommandLine(virConnectPtr conn,
}
}
+# if ! ( defined __s390x__ || defined __s390__ )
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
for (i = 0 ; i < def->ncontrollers ; i++) {
virDomainControllerDefPtr cont = def->controllers[i];
@@ -3008,6 +3038,7 @@ qemuBuildCommandLine(virConnectPtr conn,
VIR_FREE(devstr);
}
}
+# endif
/* If QEMU supports -drive param instead of old -hda, -hdb, -cdrom
.. */
if (qemuCmdFlags & QEMUD_CMD_FLAG_DRIVE) {
@@ -3106,6 +3137,7 @@ qemuBuildCommandLine(virConnectPtr conn,
}
}
+# if ! ( defined __s390x__ || defined __s390__ ) // s390x doesn't need
DeviceArg yet (it doesn't even work with ...)
if (withDeviceArg) {
if (disk->bus == VIR_DOMAIN_DISK_BUS_FDC) {
virCommandAddArg(cmd, "-global");
@@ -3131,6 +3163,7 @@ qemuBuildCommandLine(virConnectPtr conn,
VIR_FREE(optstr);
}
}
+# endif
}
} else {
for (i = 0 ; i < def->ndisks ; i++) {
@@ -3277,11 +3310,13 @@ qemuBuildCommandLine(virConnectPtr conn,
char vhostfd_name[50] = "";
int vlan;
+# if ! ( defined __s390x__ || defined __s390__ )
/* VLANs are not used with -netdev, so don't record them */
if ((qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV) &&
(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE))
vlan = -1;
else
+# endif
vlan = i;
if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
@@ -3338,6 +3373,7 @@ qemuBuildCommandLine(virConnectPtr conn,
*
* NB, no support for -netdev without use of -device
*/
+# if ! ( defined __s390x__ || defined __s390__ ) // Old way works on
IBM z9 Tuebingen; maybe there are other z9's which also work with
"semi-" or "best way"
if ((qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV) &&
(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
virCommandAddArg(cmd, "-netdev");
@@ -3354,21 +3390,26 @@ qemuBuildCommandLine(virConnectPtr conn,
virCommandAddArg(cmd, nic);
VIR_FREE(nic);
} else {
+# endif
virCommandAddArg(cmd, "-net");
if (!(nic = qemuBuildNicStr(net, "nic,", vlan)))
goto error;
virCommandAddArg(cmd, nic);
VIR_FREE(nic);
+# if ! ( defined __s390x__ || defined __s390__ )
}
if (!((qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV) &&
(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE))) {
+# endif
virCommandAddArg(cmd, "-net");
if (!(host = qemuBuildHostNetStr(net, ',', vlan,
tapfd_name,
vhostfd_name)))
goto error;
virCommandAddArg(cmd, host);
VIR_FREE(host);
+# if ! ( defined __s390x__ || defined __s390__ )
}
+# endif
}
}
@@ -3384,6 +3425,7 @@ qemuBuildCommandLine(virConnectPtr conn,
/* Use -chardev with -device if they are available */
if ((qemuCmdFlags & QEMUD_CMD_FLAG_CHARDEV) &&
(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
+# if ! ( defined __s390x__ || defined __s390__ )
virCommandAddArg(cmd, "-chardev");
if (!(devstr = qemuBuildChrChardevStr(&serial->source,
serial->info.alias)))
@@ -3394,6 +3436,7 @@ qemuBuildCommandLine(virConnectPtr conn,
virCommandAddArg(cmd, "-device");
virCommandAddArgFormat(cmd, "isa-serial,chardev=%s",
serial->info.alias);
+# endif;
} else {
virCommandAddArg(cmd, "-serial");
if (!(devstr = qemuBuildChrArgStr(&serial->source, NULL)))
@@ -3483,6 +3526,11 @@ qemuBuildCommandLine(virConnectPtr conn,
virCommandAddArg(cmd, devstr);
VIR_FREE(devstr);
+# if ( defined __s390x__ || defined __s390__ )
+ virCommandAddArg(cmd, "-device");
+ virCommandAddArg(cmd, "virtio-serial-s390");
+# endif
+
virCommandAddArg(cmd, "-device");
if (!(devstr = qemuBuildVirtioSerialPortDevStr(channel)))
goto error;
@@ -3512,6 +3560,11 @@ qemuBuildCommandLine(virConnectPtr conn,
virCommandAddArg(cmd, devstr);
VIR_FREE(devstr);
+# if ( defined __s390x__ || defined __s390__ )
+ virCommandAddArg(cmd, "-device");
+ virCommandAddArg(cmd, "virtio-serial-s390");
+# endif
+
virCommandAddArg(cmd, "-device");
if (!(devstr = qemuBuildVirtioSerialPortDevStr(console)))
goto error;
@@ -4011,6 +4064,8 @@ qemuBuildCommandLine(virConnectPtr conn,
* NB: Earlier we declared that VirtIO balloon will always be in
* slot 0x3 on bus 0x0
*/
+// our SUSE Enterprise, running on one LPAR (IBM z9), doesn't have
ballon support ...
+# if ! ( defined __s390x__ || defined __s390__ )
if ((def->memballoon) &&
(def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_NONE)) {
if (def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) {
@@ -4032,6 +4087,7 @@ qemuBuildCommandLine(virConnectPtr conn,
virCommandAddArgList(cmd, "-balloon", "virtio", NULL);
}
}
+# endif
if (current_snapshot && current_snapshot->def->active)
virCommandAddArgList(cmd, "-loadvm", current_snapshot->def->name,
13 years, 10 months
[libvirt] [PATCH] bugfix for https://bugzilla.redhat.com/show_bug.cgi?id=671050
by Michal Privoznik
virsh simply refutes to detach-interface in case when multiple interfaces are attached and --mac is not specified.
---
tools/virsh.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index aba7945..f965fc0 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -8557,6 +8557,11 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
+ if ((!mac) && (obj->nodesetval->nodeNr > 1)) {
+ vshError(ctl, _("Domain has %d interfaces. Please specify which one you want to detach using --mac"), obj->nodesetval->nodeNr);
+ goto cleanup;
+ }
+
if (!mac)
goto hit;
--
1.7.3.5
13 years, 10 months
[libvirt] [PATCH] dispatch error before return
by Wen Congyang
Signed-off-by: Wen Congyang <wency(a)cn.fujitsu.com>
---
src/libvirt.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 5f8b131..c65b1e5 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -5560,6 +5560,7 @@ virDomainAttachDeviceFlags(virDomainPtr domain,
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virDispatchError(NULL);
return -1;
}
if (domain->conn->flags & VIR_CONNECT_RO) {
@@ -5660,6 +5661,7 @@ virDomainDetachDeviceFlags(virDomainPtr domain,
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virDispatchError(NULL);
return -1;
}
if (domain->conn->flags & VIR_CONNECT_RO) {
@@ -5719,6 +5721,7 @@ virDomainUpdateDeviceFlags(virDomainPtr domain,
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virDispatchError(NULL);
return -1;
}
if (domain->conn->flags & VIR_CONNECT_RO) {
--
1.7.1
13 years, 10 months
[libvirt] [PATCH] build: avoid corrupted gnulib/tests/Makefile
by Eric Blake
Running 'make check' can sometimes fail in the gnulib/tests
subdirectory, when doing an incremental build, because
./bootstrap generates a Makefile.am that tries to refer to
../../.. instead of ../.., and gets lost.
This may be an upstream gnulib bug, where a more elegant
solution will present itself in the future:
http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/24898
But in the meantime, I was able to reproduce both the issue,
and this solution to work around it.
* bootstrap.conf (bootstrap_epilogue): Ensure that no stray
../../.. components remain in gnulib/tests/Makefile.in.
Reported by Serge Hallyn.
---
bootstrap.conf | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index 88832d1..14d5ace 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -168,0 +168,0 @@ touch ChangeLog || exit 1
bootstrap_epilogue()
{
- # Change paths in gnulib/tests/Makefile.am from "../../.." to "../..".
+ # Change paths in gnulib/tests/Makefile.am from "../../.." to "../..",
+ # then ensure that gnulib/tests/Makefile.in is up-to-date.
m=gnulib/tests/Makefile.am
sed 's,\.\./\.\./\.\.,../..,g' $m > $m-t
mv -f $m-t $m
+ ${AUTOMAKE-automake} gnulib/tests/Makefile
}
--
1.7.3.4
13 years, 10 months
[libvirt] [PATCH v5] qemu: sound: Support intel 'ich6' model
by Cole Robinson
In QEMU, the card itself is a PCI device, but it requires a codec
(either -device hda-output or -device hda-duplex) to actually output
sound. Specifying <sound model='ich6'/> gives us -device intel-hda
-device hda-duplex I think it's important that a simple <sound model='ich6'/>
sets up a useful codec, to have consistent behavior with all other sound cards.
This is basically Dan's proposal of
<sound model='ich6'>
<codec type='output' slot='0'/>
<codec type='duplex' slot='3'/>
</sound>
without the codec bits implemented.
The important thing is to keep a consistent API here, we don't want some
<sound> devs require tweaking codecs but not others. Steps I see to
accomplishing this:
- every <sound> device has a <codec type='default'/> (unless codecs are
manually specified)
- <codec type='none'/> is required to specify 'no codecs'
- new audio settings like mic=on|off could then be exposed in
<sound> or <codec> in a consistent manner for all sound models
v2:
Use model='ich6'
v3:
Use feature detection, from eblake
Set codec id, bus, and cad values
v4:
intel-hda isn't supported if -device isn't available
v5:
Comment spelling fixes
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
docs/formatdomain.html.in | 5 +-
docs/schemas/domain.rng | 1 +
src/conf/domain_conf.c | 3 +-
src/conf/domain_conf.h | 1 +
src/qemu/qemu_capabilities.c | 5 ++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 56 +++++++++++++++++++-
.../qemuxml2argv-sound-device.args | 2 +-
.../qemuxml2argvdata/qemuxml2argv-sound-device.xml | 1 +
tests/qemuxml2argvtest.c | 2 +-
10 files changed, 70 insertions(+), 7 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 859f3fd..e7f65ad 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1880,8 +1880,9 @@ qemu-kvm -net nic,model=? /dev/null
The <code>sound</code> element has one mandatory attribute,
<code>model</code>, which specifies what real sound device is emulated.
Valid values are specific to the underlying hypervisor, though typical
- choices are 'es1370', 'sb16', and 'ac97'
- (<span class="since">'ac97' only since 0.6.0</span>)
+ choices are 'es1370', 'sb16', 'ac97', and 'ich6'
+ (<span class="since">
+ 'ac97' only since 0.6.0, 'ich6' only since 0.8.8</span>)
</dd>
</dl>
diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index d4756e6..b2f8e00 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1530,6 +1530,7 @@
<value>es1370</value>
<value>pcspk</value>
<value>ac97</value>
+ <value>ich6</value>
</choice>
</attribute>
<optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 699fee7..d5445a4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -231,7 +231,8 @@ VIR_ENUM_IMPL(virDomainSoundModel, VIR_DOMAIN_SOUND_MODEL_LAST,
"sb16",
"es1370",
"pcspk",
- "ac97")
+ "ac97",
+ "ich6")
VIR_ENUM_IMPL(virDomainMemballoonModel, VIR_DOMAIN_MEMBALLOON_MODEL_LAST,
"virtio",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 3b00ba0..fc69627 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -480,6 +480,7 @@ enum virDomainSoundModel {
VIR_DOMAIN_SOUND_MODEL_ES1370,
VIR_DOMAIN_SOUND_MODEL_PCSPK,
VIR_DOMAIN_SOUND_MODEL_AC97,
+ VIR_DOMAIN_SOUND_MODEL_ICH6,
VIR_DOMAIN_SOUND_MODEL_LAST
};
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index faf7d44..02865e4 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1079,6 +1079,11 @@ cleanup:
int
qemuCapsParseDeviceStr(const char *str, unsigned long long *flags)
{
+ /* Which devices exist. */
+ if (strstr(str, "name \"hda-duplex\""))
+ *flags |= QEMUD_CMD_FLAG_HDA_DUPLEX;
+
+ /* Features of given devices. */
if (strstr(str, "pci-assign.configfd"))
*flags |= QEMUD_CMD_FLAG_PCI_CONFIGFD;
if (strstr(str, "virtio-blk-pci.bootindex"))
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index e9e2da0..9148d90 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -84,6 +84,7 @@ enum qemuCapsFlags {
QEMUD_CMD_FLAG_VGA_NONE = (1LL << 47), /* The 'none' arg for '-vga' */
QEMUD_CMD_FLAG_MIGRATE_QEMU_FD = (1LL << 48), /* -incoming fd:n */
QEMUD_CMD_FLAG_BOOTINDEX = (1LL << 49), /* -device bootindex property */
+ QEMUD_CMD_FLAG_HDA_DUPLEX = (1LL << 50), /* -device hda-duplex */
};
virCapsPtr qemuCapsInit(virCapsPtr old_caps);
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c20f031..6dc586f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1774,11 +1774,13 @@ qemuBuildSoundDevStr(virDomainSoundDefPtr sound)
goto error;
}
- /* Hack for 2 wierdly unusal devices name in QEMU */
+ /* Hack for weirdly unusual devices name in QEMU */
if (STREQ(model, "es1370"))
model = "ES1370";
else if (STREQ(model, "ac97"))
model = "AC97";
+ else if (STREQ(model, "ich6"))
+ model = "intel-hda";
virBufferVSprintf(&buf, "%s", model);
virBufferVSprintf(&buf, ",id=%s", sound->info.alias);
@@ -1797,6 +1799,29 @@ error:
return NULL;
}
+static char *
+qemuBuildSoundCodecStr(virDomainSoundDefPtr sound,
+ const char *codec)
+{
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+ int cad = 0;
+
+ virBufferVSprintf(&buf, "%s", codec);
+ virBufferVSprintf(&buf, ",id=%s-codec%d", sound->info.alias, cad);
+ virBufferVSprintf(&buf, ",bus=%s.0", sound->info.alias);
+ virBufferVSprintf(&buf, ",cad=%d", cad);
+
+ if (virBufferError(&buf)) {
+ virReportOOMError();
+ goto error;
+ }
+
+ return virBufferContentAndReset(&buf);
+
+error:
+ virBufferFreeAndReset(&buf);
+ return NULL;
+}
static char *
qemuBuildVideoDevStr(virDomainVideoDefPtr video)
@@ -3817,11 +3842,29 @@ qemuBuildCommandLine(virConnectPtr conn,
virCommandAddArgList(cmd, "-soundhw", "pcspk", NULL);
} else {
virCommandAddArg(cmd, "-device");
-
if (!(str = qemuBuildSoundDevStr(sound)))
goto error;
virCommandAddArg(cmd, str);
+
+ if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6) {
+ char *codecstr = NULL;
+ if (!(qemuCmdFlags & QEMUD_CMD_FLAG_HDA_DUPLEX)) {
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("this QEMU binary lacks hda support"));
+ goto error;
+ }
+
+ virCommandAddArg(cmd, "-device");
+ if (!(codecstr = qemuBuildSoundCodecStr(sound,
+ "hda-duplex"))) {
+ goto error;
+ }
+
+ virCommandAddArg(cmd, codecstr);
+ VIR_FREE(codecstr);
+ }
+
VIR_FREE(str);
}
}
@@ -3840,6 +3883,13 @@ qemuBuildCommandLine(virConnectPtr conn,
"%s", _("invalid sound model"));
goto error;
}
+
+ if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6) {
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("this QEMU binary lacks hda support"));
+ goto error;
+ }
+
strncat(modstr, model, size);
size -= strlen(model);
if (i < (def->nsounds - 1))
@@ -5675,6 +5725,8 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
type = VIR_DOMAIN_SOUND_MODEL_ES1370;
} else if (STRPREFIX(start, "ac97")) {
type = VIR_DOMAIN_SOUND_MODEL_AC97;
+ } else if (STRPREFIX(start, "hda")) {
+ type = VIR_DOMAIN_SOUND_MODEL_ICH6;
}
if (type != -1) {
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args
index 6b2e697..4c5172f 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args
@@ -1 +1 @@
-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 -hda /dev/HostVG/QEMUGuest1 -usb -soundhw pcspk -device ES1370,id=sound1,bus=pci.0,addr=0x2 -device sb16,id=sound2 -device AC97,id=sound3,bus=pci.0,addr=0x3 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
+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 -hda /dev/HostVG/QEMUGuest1 -usb -soundhw pcspk -device ES1370,id=sound1,bus=pci.0,addr=0x2 -device sb16,id=sound2 -device AC97,id=sound3,bus=pci.0,addr=0x3 -device intel-hda,id=sound4,bus=pci.0,addr=0x4 -device hda-duplex,id=sound4-codec0,bus=sound4.0,cad=0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.xml b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.xml
index c725346..fbca4fe 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.xml
@@ -22,6 +22,7 @@
<sound model='es1370'/>
<sound model='sb16'/>
<sound model='ac97'/>
+ <sound model='ich6'/>
<memballoon model='virtio'/>
</devices>
</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index a7270ec..0c0693b 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -418,7 +418,7 @@ mymain(int argc, char **argv)
QEMUD_CMD_FLAG_NODEFCONFIG, false);
DO_TEST("sound", 0, false);
DO_TEST("sound-device", QEMUD_CMD_FLAG_DEVICE |
- QEMUD_CMD_FLAG_NODEFCONFIG, false);
+ QEMUD_CMD_FLAG_NODEFCONFIG | QEMUD_CMD_FLAG_HDA_DUPLEX, false);
DO_TEST("fs9p", QEMUD_CMD_FLAG_DEVICE |
QEMUD_CMD_FLAG_NODEFCONFIG | QEMUD_CMD_FLAG_FSDEV, false);
--
1.7.3.2
13 years, 10 months
[libvirt] [PATCH] Fix leak in SCSI storage backend
by Daniel P. Berrange
The SCSI storage backend leaks a string containing the pathname
for each block device it discovers
* src/storage/storage_backend_scsi.c: Free the device name
---
src/storage/storage_backend_scsi.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index 95ae546..d880d65 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -455,6 +455,7 @@ processLU(virStoragePoolObjPtr pool,
VIR_FREE(type_path);
out:
+ VIR_FREE(block_device);
return retval;
}
--
1.7.3.4
13 years, 10 months