[libvirt] [PATCH] Implement support for virtio plan9fs filesystem passthrough in QEMU
by Daniel P. Berrange
Make use of the existing <filesystem> element to support plan9fs
filesystem passthrough in the QEMU driver
<filesystem type='mount'>
<source dir='/export/to/guest'/>
<target dir='/import/from/host'/>
</filesystem>
NB, the target is not actually a directory, it is merely a arbitrary
string tag that is exported to the guest as a hint for where to mount
it.
---
src/qemu/qemu_conf.c | 96 +++++++++++++++++++++++++
src/qemu/qemu_conf.h | 5 ++
tests/qemuxml2argvdata/qemuxml2argv-fs9p.args | 1 +
tests/qemuxml2argvdata/qemuxml2argv-fs9p.xml | 28 +++++++
tests/qemuxml2argvtest.c | 1 +
5 files changed, 131 insertions(+), 0 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-fs9p.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-fs9p.xml
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 16d2f44..511b9de 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1188,6 +1188,8 @@ static unsigned long long qemudComputeCmdFlags(const char *help,
flags |= QEMUD_CMD_FLAG_NO_KVM_PIT;
if (strstr(help, "-tdf"))
flags |= QEMUD_CMD_FLAG_TDF;
+ if (strstr(help, "-fsdev"))
+ flags |= QEMUD_CMD_FLAG_FSDEV;
/* Keep disabled till we're actually ready to turn on netdev mode
* The plan is todo it in 0.13.0 QEMU, but lets wait & see... */
@@ -1969,6 +1971,10 @@ qemuAssignDeviceAliases(virDomainDefPtr def, unsigned long long qemuCmdFlags)
if (!(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE))
return 0;
+ for (i = 0; i < def->nfss ; i++) {
+ if (virAsprintf(&def->fss[i]->info.alias, "fs%d", i) < 0)
+ goto no_memory;
+ }
for (i = 0; i < def->nsounds ; i++) {
if (virAsprintf(&def->sounds[i]->info.alias, "sound%d", i) < 0)
goto no_memory;
@@ -2248,6 +2254,15 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, qemuDomainPCIAddressSetPtr addrs)
if (qemuDomainPCIAddressSetNextAddr(addrs, &def->disks[i]->info) < 0)
goto error;
}
+ for (i = 0; i < def->nfss ; i++) {
+ if (def->fss[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
+ continue;
+
+ /* Only support VirtIO-9p-pci so far. If that changes,
+ * we might need to skip devices here */
+ if (qemuDomainPCIAddressSetNextAddr(addrs, &def->fss[i]->info) < 0)
+ goto error;
+ }
for (i = 0; i < def->nnets ; i++) {
if (def->nets[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
@@ -2646,6 +2661,64 @@ error:
}
+char *qemuBuildFSStr(virDomainFSDefPtr fs,
+ unsigned long long qemuCmdFlags ATTRIBUTE_UNUSED)
+{
+ virBuffer opt = VIR_BUFFER_INITIALIZER;
+
+ if (fs->type != VIR_DOMAIN_FS_TYPE_MOUNT) {
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("can only passthrough directories"));
+ goto error;
+ }
+
+ virBufferAddLit(&opt, "local");
+ virBufferVSprintf(&opt, ",id=%s%s", QEMU_FSDEV_HOST_PREFIX, fs->info.alias);
+ virBufferVSprintf(&opt, ",path=%s", fs->src);
+
+ if (virBufferError(&opt)) {
+ virReportOOMError();
+ goto error;
+ }
+
+ return virBufferContentAndReset(&opt);
+
+error:
+ virBufferFreeAndReset(&opt);
+ return NULL;
+}
+
+
+char *
+qemuBuildFSDevStr(virDomainFSDefPtr fs)
+{
+ virBuffer opt = VIR_BUFFER_INITIALIZER;
+
+ if (fs->type != VIR_DOMAIN_FS_TYPE_MOUNT) {
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("can only passthrough directories"));
+ goto error;
+ }
+
+ virBufferAddLit(&opt, "virtio-9p-pci");
+ virBufferVSprintf(&opt, ",id=%s", fs->info.alias);
+ virBufferVSprintf(&opt, ",fsdev=%s%s", QEMU_FSDEV_HOST_PREFIX, fs->info.alias);
+ virBufferVSprintf(&opt, ",mount_tag=%s", fs->dst);
+ qemuBuildDeviceAddressStr(&opt, &fs->info);
+
+ if (virBufferError(&opt)) {
+ virReportOOMError();
+ goto error;
+ }
+
+ return virBufferContentAndReset(&opt);
+
+error:
+ virBufferFreeAndReset(&opt);
+ return NULL;
+}
+
+
char *
qemuBuildControllerDevStr(virDomainControllerDefPtr def)
{
@@ -4176,6 +4249,29 @@ int qemudBuildCommandLine(virConnectPtr conn,
}
}
+ if (qemuCmdFlags & QEMUD_CMD_FLAG_FSDEV) {
+ for (i = 0 ; i < def->nfss ; i++) {
+ char *optstr;
+ virDomainFSDefPtr fs = def->fss[i];
+
+ ADD_ARG_LIT("-fsdev");
+ if (!(optstr = qemuBuildFSStr(fs, qemuCmdFlags)))
+ goto error;
+ ADD_ARG(optstr);
+
+ ADD_ARG_LIT("-device");
+ if (!(optstr = qemuBuildFSDevStr(fs)))
+ goto error;
+ ADD_ARG(optstr);
+ }
+ } else {
+ if (def->nfss) {
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("filesystem passthrough not supported by this QEMU"));
+ goto error;
+ }
+ }
+
if (!def->nnets) {
/* If we have -device, then we set -nodefault already */
if (!(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 0f8a1b3..81ae3e2 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -90,6 +90,7 @@ enum qemud_cmd_flags {
QEMUD_CMD_FLAG_NO_KVM_PIT = (1LL << 34), /* -no-kvm-pit-reinjection supported */
QEMUD_CMD_FLAG_TDF = (1LL << 35), /* -tdf flag (user-mode pit catchup) */
QEMUD_CMD_FLAG_PCI_CONFIGFD = (1LL << 36), /* pci-assign.configfd */
+ QEMUD_CMD_FLAG_FSDEV = (1LL << 37), /* -fstype filesystem passthrough */
};
/* Main driver state */
@@ -173,6 +174,7 @@ typedef qemuDomainPCIAddressSet *qemuDomainPCIAddressSetPtr;
# define QEMU_DRIVE_HOST_PREFIX "drive-"
# define QEMU_VIRTIO_SERIAL_PREFIX "virtio-serial"
+# define QEMU_FSDEV_HOST_PREFIX "fsdev-"
# define qemuReportError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_QEMU, code, __FILE__, \
@@ -233,9 +235,12 @@ char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk,
char *qemuBuildDriveStr(virDomainDiskDefPtr disk,
int bootable,
unsigned long long qemuCmdFlags);
+char *qemuBuildFSStr(virDomainFSDefPtr fs,
+ unsigned long long qemuCmdFlags);
/* Current, best practice */
char * qemuBuildDriveDevStr(virDomainDiskDefPtr disk);
+char * qemuBuildFSDevStr(virDomainFSDefPtr fs);
/* Current, best practice */
char * qemuBuildControllerDevStr(virDomainControllerDefPtr def);
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-fs9p.args b/tests/qemuxml2argvdata/qemuxml2argv-fs9p.args
new file mode 100644
index 0000000..42c26a2
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-fs9p.args
@@ -0,0 +1 @@
+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 -hda /dev/HostVG/QEMUGuest1 -fsdev local,id=fsdev-fs0,path=/export/to/guest -device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=/import/from/host,bus=pci.0,addr=0x4 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-fs9p.xml b/tests/qemuxml2argvdata/qemuxml2argv-fs9p.xml
new file mode 100644
index 0000000..9072ead
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-fs9p.xml
@@ -0,0 +1,28 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</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='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <filesystem type='mount'>
+ <source dir='/export/to/guest'/>
+ <target dir='/import/from/host'/>
+ </filesystem>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 9e4d5bf..4eb7ad8 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -335,6 +335,7 @@ mymain(int argc, char **argv)
DO_TEST("watchdog-device", QEMUD_CMD_FLAG_DEVICE);
DO_TEST("sound", 0);
DO_TEST("sound-device", QEMUD_CMD_FLAG_DEVICE);
+ DO_TEST("fs9p", QEMUD_CMD_FLAG_DEVICE | QEMUD_CMD_FLAG_FSDEV);
DO_TEST("hostdev-usb-address", 0);
DO_TEST("hostdev-usb-address-device", QEMUD_CMD_FLAG_DEVICE);
--
1.6.6.1
14 years, 5 months
[libvirt] Fwd: How do you disable hpet in a kvm?
by Richard W.M. Jones
Forwarding to libvir-list.
The KVM developers have been recommending that all guests use -no-hpet
flag. Indeed, we've been adding this flag in libguestfs for quite a
long time. However I notice that libvirt [in Rawhide] does not
include this flag for my guests.
Rich.
----- Forwarded message from "Frederick N. Brier" <fnbrier(a)gmail.com> -----
Subject: [fedora-virt] How do you disable hpet in a kvm?
Date: Tue, 08 Jun 2010 14:15:06 -0400
To: virt(a)lists.fedoraproject.org
I installed PBX In A Flash (PIAF) as a VM on a Fedora 11 64 bit host.
PIAF is a 32 bit CentOS 5.2 distro for running Asterisk. I, like many
others, am getting the error message "rtc: lost some interrupts at 1024hz"
repeating over and over on the console. Some people have apparently gotten
rid of this error message by disabling hpet in the BIOS. However, this is
a VM (kvm).
I tried adding nohpet as a kernel parameter in /boot/grub/menu.lst, but
that effects the linux OS, not the BIOS. It did not fix it.
I found references to a -no-hpet qemu parameter. However, I cannot find
how to set it in a VM created using virt-manager and an ISO image. In the
/etc/libvirt of the host I found XML configuration files describing the
VMs. These appear to be the same as those created using the virsh dumpxml
command. There does not appear to be an XML element as there is for acpi
and apic. The man page describing the XML format does not have an HPET
related option. I could not find an example or sample of it being disabled
in a libvirt XML file. Nor does there appear to be a schema (xsd or dtd)
for the libvirt file format, which might have had an hpet element or
attribute.
Ideally, is there a way to disable HPET in the BIOS for a specific VM, and
not all VMs. Thank you.
Fred
//
_______________________________________________
virt mailing list
virt(a)lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/virt
----- End forwarded message -----
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
New in Fedora 11: Fedora Windows cross-compiler. Compile Windows
programs, test, and build Windows installers. Over 70 libraries supprt'd
http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
14 years, 5 months
[libvirt] [PATCH] Correct two memory leaks triggered by udev events
by Nigel Jones
Hi List,
Please find below a patch that should correct two memory leaks within
the udev device handling code.
The issue is triggered by 'add' udev calls and will slowly cause
libvirtd to consume the majority of system memory.
The first part of the patch deals with udevAddOneDevice() and frees
the memory allocated to 'def' if the function would return -1 (an
error condition) due to the inability to look up udev properties (for
example, if the udev device is already removed).
The second part of the patch deals with a remaining 8kB/cycle memory
leak, in which the udev device reference isn't released at the end of
running udevEventHandleCallback().
I'm happy to answer any questions about the patch, there is also a bit
more background at
https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/571093
---
>From 6c8183e83fbfeb031b16cf9ae2d41b16e3145378 Mon Sep 17 00:00:00 2001
From: Nigel Jones <dev(a)nigelj.com>
Date: Mon, 24 May 2010 15:05:53 +0000
Subject: [PATCH] Patch 2 memory leaks.
1. Ensure that memory is free'd from udevAddOneDevice() if the return
value will be non-zero
2. Release udev device reference in udevEventHandleCallback()
similar to the release of the reference in udevProcessDeviceListEntry()
---
src/node_device/node_device_udev.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/node_device/node_device_udev.c
b/src/node_device/node_device_udev.c
index a1ced87..4d0effa 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1296,6 +1296,9 @@ static int udevAddOneDevice(struct udev_device *device)
ret = 0;
out:
+ if (ret != 0) {
+ virNodeDeviceDefFree(def); /* Free assigned memory to prevent leaks */
+ }
return ret;
}
@@ -1426,6 +1429,7 @@ static void udevEventHandleCallback(int watch
ATTRIBUTE_UNUSED,
}
out:
+ udev_device_unref(device);
return;
}
--
1.7.0.4
14 years, 5 months
[libvirt] [PATCH] virsh: add snapshot backing store support to vol-create-as
by Justin Clift
This patch adds two new parameters to the vol-create-as command:
--snapshot-backing-vol <volume-name-or-key-or-path>
--snapshot-backing-vol-format <format-of-backing-vol>
virsh # vol-create-as guest_images_lvm snapvol1 5G --snapshot-backing-vol \
rhel6vm1lun1
Vol snapvol1 created
virsh # vol-create-as image_dir qcow2snap2 5G --format qcow2 \
--snapshot-backing-vol imagevol1.qcow2 \
--snapshot-backing-vol-format qcow2
Vol qcow2snap2 created
Additionally, the virsh man page update fixes incorrect snapshot
parameters that were included in my prior bulk volume command patch.
---
tools/virsh.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
tools/virsh.pod | 10 ++++----
2 files changed, 65 insertions(+), 6 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 1e00114..497c7d4 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -5274,6 +5274,8 @@ static const vshCmdOptDef opts_vol_create_as[] = {
{"capacity", VSH_OT_DATA, VSH_OFLAG_REQ, N_("size of the vol with optional k,M,G,T suffix")},
{"allocation", VSH_OT_STRING, 0, N_("initial allocation size with optional k,M,G,T suffix")},
{"format", VSH_OT_STRING, 0, N_("file format type raw,bochs,qcow,qcow2,vmdk")},
+ {"snapshot-backing-vol", VSH_OT_STRING, 0, N_("the backing volume if taking a snapshot")},
+ {"snapshot-backing-vol-format", VSH_OT_STRING, 0, N_("format of backing volume if taking a snapshot")},
{NULL, 0, 0, NULL}
};
@@ -5313,6 +5315,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
int found;
char *xml;
char *name, *capacityStr, *allocationStr, *format;
+ char *snapshotStrVol, *snapshotStrFormat;
unsigned long long capacity, allocation = 0;
virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -5339,6 +5342,8 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
vshError(ctl, _("Malformed size %s"), allocationStr);
format = vshCommandOptString(cmd, "format", &found);
+ snapshotStrVol = vshCommandOptString(cmd, "snapshot-backing-vol", &found);
+ snapshotStrFormat = vshCommandOptString(cmd, "snapshot-backing-vol-format", &found);
virBufferAddLit(&buf, "<volume>\n");
virBufferVSprintf(&buf, " <name>%s</name>\n", name);
@@ -5351,8 +5356,62 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
virBufferVSprintf(&buf, " <format type='%s'/>\n",format);
virBufferAddLit(&buf, " </target>\n");
}
- virBufferAddLit(&buf, "</volume>\n");
+ /* Convert the snapshot parameters into backingStore XML */
+ if (snapshotStrVol) {
+ /* Lookup snapshot backing volume. Try the snapshot-backing-vol
+ * parameter as a name */
+ vshDebug(ctl, 5, "%s: Look up backing store volume '%s' as name\n",
+ cmd->def->name, snapshotStrVol);
+ virStorageVolPtr snapVol = virStorageVolLookupByName(pool, snapshotStrVol);
+ if (snapVol)
+ vshDebug(ctl, 5, "%s: Backing store volume found using '%s' as name\n",
+ cmd->def->name, snapshotStrVol);
+
+ if (snapVol == NULL) {
+ /* Snapshot backing volume not found by name. Try the
+ * snapshot-backing-vol parameter as a key */
+ vshDebug(ctl, 5, "%s: Look up backing store volume '%s' as key\n",
+ cmd->def->name, snapshotStrVol);
+ snapVol = virStorageVolLookupByKey(ctl->conn, snapshotStrVol);
+ if (snapVol)
+ vshDebug(ctl, 5, "%s: Backing store volume found using '%s' as key\n",
+ cmd->def->name, snapshotStrVol);
+ }
+ if (snapVol == NULL) {
+ /* Snapshot backing volume not found by key. Try the
+ * snapshot-backing-vol parameter as a path */
+ vshDebug(ctl, 5, "%s: Look up backing store volume '%s' as path\n",
+ cmd->def->name, snapshotStrVol);
+ snapVol = virStorageVolLookupByPath(ctl->conn, snapshotStrVol);
+ if (snapVol)
+ vshDebug(ctl, 5, "%s: Backing store volume found using '%s' as path\n",
+ cmd->def->name, snapshotStrVol);
+ }
+ if (snapVol == NULL) {
+ vshError(ctl, _("failed to get vol '%s'"), snapshotStrVol);
+ return FALSE;
+ }
+
+ char *snapshotStrVolPath;
+ if ((snapshotStrVolPath = virStorageVolGetPath(snapVol)) == NULL) {
+ virStorageVolFree(snapVol);
+ return FALSE;
+ }
+
+ /* Create XML for the backing store */
+ virBufferAddLit(&buf, " <backingStore>\n");
+ virBufferVSprintf(&buf, " <path>%s</path>\n",snapshotStrVolPath);
+ if (snapshotStrFormat)
+ virBufferVSprintf(&buf, " <format type='%s'/>\n",snapshotStrFormat);
+ virBufferAddLit(&buf, " </backingStore>\n");
+
+ /* Cleanup snapshot allocations */
+ VIR_FREE(snapshotStrVolPath);
+ virStorageVolFree(snapVol);
+ }
+
+ virBufferAddLit(&buf, "</volume>\n");
if (virBufferError(&buf)) {
vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 3b0cf16..7039ad2 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -782,8 +782,8 @@ source volume is in.
I<vol-name-or-key-or-path> is the name or key or path of the source volume.
=item B<vol-create-as> I<pool-or-uuid> I<name> I<capacity> optional
-I<--allocation> I<size> I<--format> I<string> I<--snapshot-source-vol>
-I<vol-name-or-key-or-path> I<--snapshot-source-format> I<string>
+I<--allocation> I<size> I<--format> I<string> I<--snapshot-backing-vol>
+I<vol-name-or-key-or-path> I<--snapshot-backing-vol-format> I<string>
Create a volume from a set of arguments.
I<pool-or-uuid> is the name or UUID of the storage pool to create the volume
@@ -795,10 +795,10 @@ I<--allocation> I<size> is the initial size to be allocated in the volume, with
optional k, M, G, or T suffix.
I<--format> I<string> is used in file based storage pools to specify the volume
file format to use; raw, bochs, qcow, qcow2, vmdk.
-I<--snapshot-source-vol> I<vol-name-or-key-or-path> is the source backing
+I<--snapshot-backing-vol> I<vol-name-or-key-or-path> is the source backing
volume to be used if taking a snapshot of an existing volume.
-I<--snapshot-source-format> I<string> is the format of the snapshot backing volume;
-raw, bochs, qcow, qcow2, vmdk.
+I<--snapshot-backing-vol-format> I<string> is the format of the snapshot backing volume;
+raw, bochs, qcow, qcow2, vmdk, host_device.
=item B<vol-clone> [optional I<--pool> I<pool-or-uuid>] I<vol-name-or-key-or-path> I<name>
--
1.7.0.1
14 years, 5 months
[libvirt] [PATCH] Enable probing of VPC disk format type
by Daniel P. Berrange
A look at the QEMU source revealed the missing bits of info about
the VPC file format, so we can enable this now
* src/util/storage_file.c: Enable VPC format, providing version
and disk size offset fields
---
src/util/storage_file.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/util/storage_file.c b/src/util/storage_file.c
index b3ae905..6cc8d5f 100644
--- a/src/util/storage_file.c
+++ b/src/util/storage_file.c
@@ -135,11 +135,9 @@ static struct FileTypeInfo const fileTypeInfo[] = {
LV_LITTLE_ENDIAN, 4, 1,
4+4+4, 8, 512, -1, vmdk4GetBackingStore },
/* Connectix / VirtualPC */
- /* XXX Untested
{ VIR_STORAGE_FILE_VPC, "conectix", NULL,
- LV_BIG_ENDIAN, -1, 0,
- -1, 0, 0, -1, NULL},
- */
+ LV_BIG_ENDIAN, 12, 0x10000,
+ 8 + 4 + 4 + 8 + 4 + 4 + 2 + 2 + 4, 8, 1, -1, NULL},
};
static int
--
1.6.6.1
14 years, 5 months
[libvirt] [PATCH] virsh: add --pool support to vol-key command
by Justin Clift
---
tools/virsh.c | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 2e8cbec..1e00114 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -5947,13 +5947,13 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
* "vol-name" command
*/
static const vshCmdInfo info_vol_name[] = {
- {"help", N_("convert a vol UUID to vol name")},
+ {"help", N_("returns the volume name for a given volume key or path")},
{"desc", ""},
{NULL, NULL}
};
static const vshCmdOptDef opts_vol_name[] = {
- {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("vol key or path")},
+ {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("volume key or path")},
{NULL, 0, 0, NULL}
};
@@ -5975,18 +5975,18 @@ cmdVolName(vshControl *ctl, const vshCmd *cmd)
}
-
/*
* "vol-key" command
*/
static const vshCmdInfo info_vol_key[] = {
- {"help", N_("convert a vol UUID to vol key")},
+ {"help", N_("returns the volume key for a given volume name or path")},
{"desc", ""},
{NULL, NULL}
};
static const vshCmdOptDef opts_vol_key[] = {
- {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("vol uuid")},
+ {"pool", VSH_OT_STRING, 0, N_("pool name or uuid")},
+ {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("volume name or path")},
{NULL, 0, 0, NULL}
};
@@ -5994,12 +5994,12 @@ static int
cmdVolKey(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
+ char *name = NULL;
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
return FALSE;
- if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", "pool", NULL,
- VSH_BYUUID)))
+ if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
return FALSE;
vshPrint(ctl, "%s\n", virStorageVolGetKey(vol));
@@ -6008,19 +6008,18 @@ cmdVolKey(vshControl *ctl, const vshCmd *cmd)
}
-
/*
* "vol-path" command
*/
static const vshCmdInfo info_vol_path[] = {
- {"help", N_("convert a vol UUID to vol path")},
+ {"help", N_("returns the volume path for a given volume name or key")},
{"desc", ""},
{NULL, NULL}
};
static const vshCmdOptDef opts_vol_path[] = {
{"pool", VSH_OT_STRING, 0, N_("pool name or uuid")},
- {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("vol name or key")},
+ {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("volume name or key")},
{NULL, 0, 0, NULL}
};
--
1.7.0.1
14 years, 5 months
[libvirt] [PATCH] virsh: remove Xen reference in header comment
by Justin Clift
---
tools/virsh.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 1279f41..e444501 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1,5 +1,5 @@
/*
- * virsh.c: a Xen shell used to exercise the libvirt API
+ * virsh.c: a shell to exercise the libvirt API
*
* Copyright (C) 2005, 2007-2010 Red Hat, Inc.
*
--
1.7.0.1
14 years, 5 months
[libvirt] PATCH: Include port number with virtio serial devices
by Daniel P. Berrange
To ensure that the device addressing scheme is stable across
hotplug/unplug, all virtio serial channels needs to have an
associated port number in their address. This is then specified
to QEMU using the nr=NNN parameter
* src/conf/domain_conf.c, src/conf/domain_conf.h: Parsing
for port number in vioserial address types.
* src/qemu/qemu_conf.c: Set 'nr=NNN' parameter with virtio
serial port number
* tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args,
tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml: Expand
data set to ensure coverage of port addressing
---
src/conf/domain_conf.c | 30 ++++++++++++++++++--
src/conf/domain_conf.h | 1 +
src/qemu/qemu_conf.c | 3 ++
.../qemuxml2argv-channel-virtio.args | 2 +-
.../qemuxml2argv-channel-virtio.xml | 14 ++++++++-
5 files changed, 45 insertions(+), 5 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 312a6c0..a9b01d5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1055,9 +1055,10 @@ static int virDomainDeviceInfoFormat(virBufferPtr buf,
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL:
- virBufferVSprintf(buf, " controller='%d' bus='%d'",
+ virBufferVSprintf(buf, " controller='%d' bus='%d' port='%d'",
info->addr.vioserial.controller,
- info->addr.vioserial.bus);
+ info->addr.vioserial.bus,
+ info->addr.vioserial.port);
break;
default:
@@ -1190,13 +1191,14 @@ virDomainDeviceVirtioSerialAddressParseXML(
virDomainDeviceVirtioSerialAddressPtr addr
)
{
- char *controller, *bus;
+ char *controller, *bus, *port;
int ret = -1;
memset(addr, 0, sizeof(*addr));
controller = virXMLPropString(node, "controller");
bus = virXMLPropString(node, "bus");
+ port = virXMLPropString(node, "port");
if (controller &&
virStrToLong_ui(controller, NULL, 10, &addr->controller) < 0) {
@@ -1212,6 +1214,13 @@ virDomainDeviceVirtioSerialAddressParseXML(
goto cleanup;
}
+ if (port &&
+ virStrToLong_ui(port, NULL, 10, &addr->port) < 0) {
+ virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Cannot parse <address> 'port' attribute"));
+ goto cleanup;
+ }
+
if (!virDomainDeviceVirtioSerialAddressIsValid(addr)) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Insufficient specification for "
@@ -4375,6 +4384,21 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
goto error;
def->channels[def->nchannels++] = chr;
+
+ if (chr->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL &&
+ chr->info.addr.vioserial.port == 0) {
+ int maxport = -1;
+ int j;
+ for (j = 0 ; j < i ; j++) {
+ virDomainChrDefPtr thischr = def->channels[j];
+ if (thischr->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL &&
+ thischr->info.addr.vioserial.controller == chr->info.addr.vioserial.controller &&
+ thischr->info.addr.vioserial.bus == chr->info.addr.vioserial.bus &&
+ (int)thischr->info.addr.vioserial.port > maxport)
+ maxport = thischr->info.addr.vioserial.port;
+ }
+ chr->info.addr.vioserial.port = maxport + 1;
+ }
}
VIR_FREE(nodes);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index f87f6c8..f83de83 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -98,6 +98,7 @@ typedef virDomainDeviceVirtioSerialAddress *virDomainDeviceVirtioSerialAddressPt
struct _virDomainDeviceVirtioSerialAddress {
unsigned int controller;
unsigned int bus;
+ unsigned int port;
};
typedef struct _virDomainDeviceInfo virDomainDeviceInfo;
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 511b9de..5521dbe 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -3312,6 +3312,9 @@ qemuBuildVirtioSerialPortDevStr(virDomainChrDefPtr dev)
",bus=" QEMU_VIRTIO_SERIAL_PREFIX "%d.%d",
dev->info.addr.vioserial.controller,
dev->info.addr.vioserial.bus);
+ virBufferVSprintf(&buf,
+ ",nr=%d",
+ dev->info.addr.vioserial.port);
}
virBufferVSprintf(&buf, ",chardev=%s", dev->info.alias);
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args
index 4097065..8e5fbe2 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.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 -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device virtio-serial-pci,id=virtio-serial0,max_ports=16,vectors=4,bus=pci.0,addr=0x4 -device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa -hda /dev/HostVG/QEMUGuest1 -chardev pty,id=channel0 -device virtserialport,chardev=channel0,name=org.linux-kvm.port.0 -chardev pty,id=channel1 -device virtserialport,bus=virtio-serial1.0,chardev=channel1,name=org.linux-kvm.port.1 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
+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 -device virtio-serial-pci,id=virtio-serial0,max_ports=16,vectors=4,bus=pci.0,addr=0x4 -device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa -hda /dev/HostVG/QEMUGuest1 -chardev pty,id=channel0 -device virtserialport,chardev=channel0,name=org.linux-kvm.port.0 -chardev pty,id=channel1 -device virtserialport,bus=virtio-serial1.0,nr=0,chardev=channel1,name=org.linux-kvm.port.foo -chardev pty,id=channel2 -device virtserialport,bus=virtio-serial1.0,nr=3,chardev=channel2,name=org.linux-kvm.port.bar -chardev pty,id=channel3 -device virtserialport,bus=virtio-serial0.0,nr=0,chardev=channel3,name=org.linux-kvm.port.wizz -chardev pty,id=channel4 -device virtserialport,bus=virtio-serial1.0,nr=4,chardev=channel4,name=org.linux-kvm.port.ooh -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml
index 6c3317b..04a3e1c 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml
@@ -28,7 +28,19 @@
<target type='virtio' name='org.linux-kvm.port.0'/>
</channel>
<channel type='pty'>
- <target type='virtio' name='org.linux-kvm.port.1'/>
+ <target type='virtio' name='org.linux-kvm.port.foo'/>
+ <address type='virtio-serial' controller='1' bus='0'/>
+ </channel>
+ <channel type='pty'>
+ <target type='virtio' name='org.linux-kvm.port.bar'/>
+ <address type='virtio-serial' controller='1' bus='0' port='3'/>
+ </channel>
+ <channel type='pty'>
+ <target type='virtio' name='org.linux-kvm.port.wizz'/>
+ <address type='virtio-serial' controller='0' bus='0'/>
+ </channel>
+ <channel type='pty'>
+ <target type='virtio' name='org.linux-kvm.port.ooh'/>
<address type='virtio-serial' controller='1' bus='0'/>
</channel>
</devices>
--
1.6.6.1
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
14 years, 5 months
[libvirt] [PATCH] Adds the missing vol-pool command to virsh.
by Justin Clift
Hi all,
This patch adds a "vol-pool" command to virsh, to round out the conversion functions for vols in virsh.
At the moment, if we start with a volume name and a pool id, we're all good. We can convert from that pair to either a volume key or volume path.
But, if we're given just a volume key or path we have no good way to look up the storage pool for it. Kind of makes it a one way association. :/
This patch fixes that, making it possible to work from just having a volume key or path. :)
Regards and best wishes,
Justin Clift
---
tools/virsh.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 1279f41..95aea0f 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -5975,6 +5975,53 @@ cmdVolName(vshControl *ctl, const vshCmd *cmd)
}
+/*
+ * "vol-pool" command
+ */
+static const vshCmdInfo info_vol_pool[] = {
+ {"help", N_("returns the storage pool for a given volume key or path")},
+ {"desc", ""},
+ {NULL, NULL}
+};
+
+static const vshCmdOptDef opts_vol_pool[] = {
+ {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("volume key or path")},
+ {NULL, 0, 0, NULL}
+};
+
+static int
+cmdVolPool(vshControl *ctl, const vshCmd *cmd)
+{
+ virStoragePoolPtr pool;
+ virStorageVolPtr vol;
+
+ // Check the connection to libvirtd daemon is still working
+ if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
+ return FALSE;
+
+ // Use the supplied string to locate the volume
+ if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", "pool", NULL,
+ VSH_BYUUID))) {
+ return FALSE;
+ }
+
+ // Look up the parent storage pool for the volume
+ pool = virStoragePoolLookupByVolume(vol);
+ if (pool == NULL) {
+ vshError(ctl, "%s", _("failed to get parent pool"));
+ virStorageVolFree(vol);
+ return FALSE;
+ }
+
+ // Return the name of the parent storage pool
+ vshPrint(ctl, "%s\n", virStoragePoolGetName(pool));
+
+ // Cleanup
+ virStorageVolFree(vol);
+ virStoragePoolFree(pool);
+ return TRUE;
+}
+
/*
* "vol-key" command
@@ -8837,6 +8884,7 @@ static const vshCmdDef commands[] = {
{"vol-dumpxml", cmdVolDumpXML, opts_vol_dumpxml, info_vol_dumpxml},
{"vol-info", cmdVolInfo, opts_vol_info, info_vol_info},
{"vol-list", cmdVolList, opts_vol_list, info_vol_list},
+ {"vol-pool", cmdVolPool, opts_vol_pool, info_vol_pool},
{"vol-path", cmdVolPath, opts_vol_path, info_vol_path},
{"vol-name", cmdVolName, opts_vol_name, info_vol_name},
{"vol-key", cmdVolKey, opts_vol_key, info_vol_key},
--
1.7.0.1
14 years, 5 months
[libvirt] [PATCH] Fix minor virsh man page typos and formatting problems.
by Justin Clift
---
tools/virsh.pod | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 422ae7f..79900e5 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -89,7 +89,7 @@ Running hypervisor: Xen 3.0.0
=back
-=item B<cd> I<directory> optional
+=item B<cd> optional I<directory>
Will change current directory to I<directory>. The default directory
for the B<cd> command is the home directory or, if there is no I<HOME>
@@ -273,13 +273,13 @@ pre-existing guest.
B<Example>
-virsh dumpxml <domain-id> > domain.xml
-edit domain.xml
-virsh create < domain.xml
+ virsh dumpxml <domain-id> > domain.xml
+ edit domain.xml
+ virsh create domain.xml
=item B<define> I<FILE>
-Define a domain from an XML <file>. The domain definitions is registered
+Define a domain from an XML <file>. The domain definition is registered
but not started.
=item B<destroy> I<domain-id>
@@ -490,7 +490,7 @@ is not available the processes will provide an exit
code of 1.
=item B<undefine> I<domain-id>
Undefine the configuration for an inactive domain. Since it's not running
-the domain name or UUId must be used as the I<domain-id>.
+the domain name or UUID must be used as the I<domain-id>.
=item B<vcpuinfo> I<domain-id>
-- 1.7.0.1
14 years, 5 months