[libvirt] [PATCH] qemu: add value range check of option granularity
by Shanzhi Yu
The default value of the granularity is the image cluster size clamped
between 4096 and 65536. Libvirt should add a check for this otherwise
qemu will report error like below:
$ virsh blockcopy r7 vda /var/lib/libvirt/images/r7.s1 --granularity 32
error: internal error: unable to execute QEMU command 'drive-mirror': Parameter 'granularity' expects a value in range [512B, 64MB]
Signed-off-by: Shanzhi Yu <shyu(a)redhat.com>
---
src/qemu/qemu_driver.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d1f195c..0eca8ed 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16990,6 +16990,10 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *disk, const char *destxml,
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("granularity must be power of 2"));
goto cleanup;
+ } else if (param->value.ui > 65536 || param->value.ui < 4096) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("granularity expects value in range [4096 65536]"));
+ goto cleanup;
}
granularity = param->value.ui;
} else if (STREQ(param->field, VIR_DOMAIN_BLOCK_COPY_BUF_SIZE)) {
--
2.4.3
9 years, 5 months
[libvirt] [sandbox v2 0/4] Getting qemu sandboxes run as root + host-image format
by Cédric Bosdonnat
Hi all,
Here are a few patches to make sandboxes run with qemu:///system connection.
The last one is just a new feature to allow using somethings else than RAW images
in host-image mounts. This feature will later be needed to run docker container
using Eren's work.
Diff to v1:
* Adapted the code to set the filesystem type due to the changes in libvirt-glib
patch (v2).
Cédric Bosdonnat (4):
Make sure the sandbox state dir and config can be accessed
Write /dev/vd* instead of vd* in mounts.cfg
qemu: mount all host-images as ext4
Add host-image format parameter
.../libvirt-sandbox-builder-container.c | 10 +++
libvirt-sandbox/libvirt-sandbox-builder-machine.c | 13 +++-
.../libvirt-sandbox-config-mount-host-image.c | 91 +++++++++++++++++++++-
.../libvirt-sandbox-config-mount-host-image.h | 5 +-
libvirt-sandbox/libvirt-sandbox-config.c | 70 +++++++++++++++--
.../libvirt-sandbox-context-interactive.c | 4 +-
libvirt-sandbox/libvirt-sandbox.sym | 5 ++
libvirt-sandbox/tests/test-config.c | 1 +
8 files changed, 186 insertions(+), 13 deletions(-)
--
2.1.4
9 years, 5 months
[libvirt] [PATCH v2 0/2] lxc: properly clean up qemu-nbd
by Cédric Bosdonnat
Hi all,
Here is the very same patch, but split in two patches. Well, I also moved
two comments around between v1 and v2.
Cédric Bosdonnat (2):
Add virProcessGetPids to get all tasks of a process
lxc: properly clean up qemu-nbd
src/libvirt_private.syms | 1 +
src/lxc/lxc_controller.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++
src/util/virprocess.c | 47 ++++++++++++++++++++++++++++++++++++++++
src/util/virprocess.h | 2 ++
4 files changed, 106 insertions(+)
--
2.1.4
9 years, 5 months
[libvirt] Publishing a Python libvirt Howto/Reference Guide
by David Ashley
All -
I represent the Fedora Docs Team. We are interested in publishing a
Python libvirt HowTo/Reference Guide for users. We feel that there is a
gap with using virtualization from a scripting environment. While virsh
fills this gap for simple scripting purposes, a more powerful scripting
language is needed for deep administrative purposes. Python is the
obvious choice and the libvirt team has provided a great Python module.
What is really missing are examples of using the module in both simple
and deeper tasks i.e. something more than just how to start and stop a
domain.
We propose to create such a document. While we can use pydoc to create
the reference material, we need some really good examples that can teach
a user how to get real work done using the classes. We also propose to
share the document with the libvirt team taking either an upstream or
downstream role in maintaining the document. The document would be
written in DocBook and published using the Publican system. This would
allow you to create your own brand for the document (look and feel)
while maintaining compatible source for both our teams. It would also
allow the source to be maintained by both teams.
If this sounds interesting to you we would like to begin our planning
for the document in the near future with one or more representatives
from the libvirt team on board. Please let either myself or Laura Novich
(cc'ed on this email) know if this proposal meets with your approval.
W. David Ashley
w.david.ashley(a)gmail.com
Fedora Docs Team
9 years, 5 months
[libvirt] [PATCH v2 0/3] Adjust netfs CIFS/Samba formatting
by John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1186969
v1 here:
http://www.redhat.com/archives/libvir-list/2015-June/msg00155.html
Changes since v1:
* Alter v1 to make a common RNG - even though it's ACK'd - I figured I'd
still send to make sure there were no other issues...
* Add 2/3 to apply comment made in former 2/2 regarding checking for
pool->def->type == VIR_STORAGE_POOL_FS to the glusterfs since it has
the same issue
* Modify 3/3 is old 2/2 and only removed the ternary check.
John Ferlan (3):
storage: Fix the schema and add tests for cifs pool
storage: Adjust command arglist for gluster
storage: Generate correct parameters for CIFS
docs/formatstorage.html.in | 7 ++++--
docs/schemas/storagepool.rng | 10 ++++----
docs/storage.html.in | 3 ++-
src/storage/storage_backend_fs.c | 31 ++++++++++++++++++-------
tests/storagepoolxml2xmlin/pool-netfs-cifs.xml | 12 ++++++++++
tests/storagepoolxml2xmlout/pool-netfs-cifs.xml | 15 ++++++++++++
tests/storagepoolxml2xmltest.c | 1 +
7 files changed, 64 insertions(+), 15 deletions(-)
create mode 100644 tests/storagepoolxml2xmlin/pool-netfs-cifs.xml
create mode 100644 tests/storagepoolxml2xmlout/pool-netfs-cifs.xml
--
2.1.0
9 years, 5 months
[libvirt] [RFC PATCHv2 0/8] new API virDomainBlockSetWriteThreshold
by Eric Blake
Still in RFC stage because I need more work on qemu to turn on
auto-node-naming, then corresponding work in libvirt to do
node name lookups for both setting the threshold and for mapping
events back to the right device name. But with this series in
place and a simple hack to qemu to allow threshold settings on
the active layer of a device (wrong node), I was able to do
round trip threshold modifications (set a number, and read it
back correctly) and rudimentary threshold event testing (I set
such a low threshold that pretty much any guest write was enough
to fire the event, although the corresponding length past the
offset was unpredictable and had no bearing on whether the host
allocation had actually changed as a result of the guest write).
Posting now, since most of these patches will be fairly similar
to their final form; only those touching src/qemu/ will need
changes, once I get the counterpart qemu patches for
auto-node-naming working and integrated.
Eric Blake (8):
threshold: new API virDomainBlockSetWriteThreshold
threshold: expose new API in virsh
threshold: new event object for tracking write threshold
threshold: wire up threshold event in RPC
threshold: add qemu capability bit
threshold: add threshold event handling in qemu
threshold: scrape threshold data from QMP
threshold: add write threshold setting in qemu
daemon/remote.c | 39 +++++++++++++++
include/libvirt/libvirt-domain.h | 47 ++++++++++++++++++
src/conf/domain_event.c | 93 +++++++++++++++++++++++++++++++++-
src/conf/domain_event.h | 14 +++++-
src/driver-hypervisor.h | 7 +++
src/libvirt-domain.c | 95 +++++++++++++++++++++++++++++++++++
src/libvirt_private.syms | 2 +
src/libvirt_public.syms | 5 ++
src/qemu/qemu_capabilities.c | 4 +-
src/qemu/qemu_capabilities.h | 3 +-
src/qemu/qemu_driver.c | 104 +++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor.c | 27 ++++++++++
src/qemu/qemu_monitor.h | 17 +++++++
src/qemu/qemu_monitor_json.c | 79 +++++++++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 3 ++
src/qemu/qemu_process.c | 34 +++++++++++++
src/remote/remote_driver.c | 34 +++++++++++++
src/remote/remote_protocol.x | 29 ++++++++++-
src/remote_protocol-structs | 15 ++++++
tests/qemumonitortest.c | 13 ++---
tools/virsh-domain-monitor.c | 81 ++++++++++++++++++++++++++++++
tools/virsh-domain.c | 23 +++++++++
tools/virsh.pod | 25 ++++++++++
23 files changed, 782 insertions(+), 11 deletions(-)
--
2.4.2
9 years, 5 months
[libvirt] [PATCH] Fix virsh edit and virt-xml-validate with SCSI LUN
by Eric Farman
Defining a domain with a SCSI disk attached via a hostdev
tag and a source address unit value longer than two digits
causes an error when editing the domain with virsh edit,
even if no changes are made to the domain definition.
The error suggests invalid XML, somewhere:
# virsh edit lmb_guest
error: XML document failed to validate against schema:
Unable to validate doc against /usr/local/share/libvirt/schemas/domain.rng
Extra element devices in interleave
Element domain failed to validate content
The virt-xml-validate tool fails with a similar error:
# virt-xml-validate lmb_guest.xml
Relax-NG validity error : Extra element devices in interleave
lmb_guest.xml:17: element devices: Relax-NG validity error :
Element domain failed to validate content
lmb_guest.xml fails to validate
The hostdev tag requires a source address to be specified,
which includes bus, target, and unit address attributes.
According to the SCSI Architecture Model spec (section
4.9 of SAM-2), a LUN address is 64 bits and thus could be
up to 20 decimal digits long. Unfortunately, the XML
schema limits this string to just two digits. Similarly,
the target field can be up to 32 bits in length, which
would be 10 decimal digits.
# lsscsi -xx
[0:0:19:0x4022401100000000] disk IBM 2107900 3.44 /dev/sda
# lsscsi
[0:0:19:1074872354]disk IBM 2107900 3.44 /dev/sda
# cat lmb_guest.xml
<domain type='kvm'>
<name>lmb_guest</name>
<memory unit='MiB'>1024</memory>
...trimmed...
<devices>
<controller type='scsi' model='virtio-scsi' index='0'/>
<hostdev mode='subsystem' type='scsi'>
<source>
<adapter name='scsi_host0'/>
<address bus='0' target='19' unit='1074872354'/>
</source>
</hostdev>
...trimmed...
Since the reference unit and target fields are used in
several places in the XML schema, create a separate one
specific for SCSI Logical Units that will permit the
greater length. Also, expand the definition of the SCSI
unit field from an int to a long long, to cover the
possible size. This permits both the validation utility
and the virsh edit command to succeed when a hostdev
tag is included.
Signed-off-by: Eric Farman <farman(a)linux.vnet.ibm.com>
Reviewed-by: Matthew Rosato <mjrosato(a)linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi(a)linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy(a)linux.vnet.ibm.com>
---
docs/formatdomain.html.in | 10 +++++++---
docs/schemas/domaincommon.rng | 14 ++++++++++++--
src/conf/domain_audit.c | 2 +-
src/conf/domain_conf.c | 4 ++--
src/conf/domain_conf.h | 2 +-
src/qemu/qemu_command.h | 2 +-
src/qemu/qemu_hotplug.c | 4 ++--
src/util/virhostdev.c | 6 +++---
src/util/virscsi.c | 16 ++++++++--------
src/util/virscsi.h | 8 ++++----
tests/testutilsqemu.c | 2 +-
tools/virsh-domain.c | 6 +++---
12 files changed, 45 insertions(+), 31 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 1781996..e7a8e1a 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2827,7 +2827,7 @@
<dd>Drive addresses have the following additional
attributes: <code>controller</code> (a 2-digit controller
number), <code>bus</code> (a 2-digit bus number),
- <code>target</code> (a 2-digit bus number),
+ <code>target</code> (a 2-digit target number),
and <code>unit</code> (a 2-digit unit number on the bus).
</dd>
<dt><code>type='virtio-serial'</code></dt>
@@ -3136,7 +3136,7 @@
<hostdev mode='subsystem' type='scsi' sgio='filtered' rawio='yes'>
<source>
<adapter name='scsi_host0'/>
- <address type='scsi' bus='0' target='0' unit='0'/>
+ <address bus='0' target='0' unit='0'/>
</source>
<readonly/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
@@ -3244,7 +3244,11 @@
</dd>
<dt>scsi</dt>
<dd>SCSI devices are described by both the <code>adapter</code>
- and <code>address</code> elements.
+ and <code>address</code> elements. The <code>address</code>
+ element includes a <code>bus</code> attribute (a 2-digit bus
+ number), a <code>target</code> attribute (a 10-digit target
+ number), and a <code>unit</code> attribute (a 20-digit unit
+ number on the bus).
<p>
<span class="since">Since 1.2.8</span>, the <code>source</code>
element of a SCSI device may contain the <code>protocol</code>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 5dc48f7..dccd3fd 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3846,10 +3846,10 @@
<ref name="driveBus"/>
</attribute>
<attribute name="target">
- <ref name="driveTarget"/>
+ <ref name="driveSCSITarget"/>
</attribute>
<attribute name="unit">
- <ref name="driveUnit"/>
+ <ref name="driveSCSIUnit"/>
</attribute>
</define>
<define name="usbportaddress">
@@ -5142,11 +5142,21 @@
<param name="pattern">[0-9]{1,2}</param>
</data>
</define>
+ <define name="driveSCSITarget">
+ <data type="string">
+ <param name="pattern">[0-9]{1,10}</param>
+ </data>
+ </define>
<define name="driveUnit">
<data type="string">
<param name="pattern">[0-9]{1,2}</param>
</data>
</define>
+ <define name="driveSCSIUnit">
+ <data type="string">
+ <param name="pattern">[0-9]{1,20}</param>
+ </data>
+ </define>
<define name="featureName">
<data type="string">
<param name='pattern'>[a-zA-Z0-9\-_\.]+</param>
diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index 1900039..844297c 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -427,7 +427,7 @@ virDomainAuditHostdev(virDomainObjPtr vm, virDomainHostdevDefPtr hostdev,
} else {
virDomainHostdevSubsysSCSIHostPtr scsihostsrc =
&scsisrc->u.host;
- if (virAsprintfQuiet(&address, "%s:%d:%d:%d",
+ if (virAsprintfQuiet(&address, "%s:%d:%d:%lld",
scsihostsrc->adapter, scsihostsrc->bus,
scsihostsrc->target,
scsihostsrc->unit) < 0) {
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 36de844..1f2bfca 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4954,7 +4954,7 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode,
goto cleanup;
}
- if (virStrToLong_ui(unit, NULL, 0, &scsihostsrc->unit) < 0) {
+ if (virStrToLong_ull(unit, NULL, 0, &scsihostsrc->unit) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse unit '%s'"), unit);
goto cleanup;
@@ -18844,7 +18844,7 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
virBufferAsprintf(buf, "<adapter name='%s'/>\n",
scsihostsrc->adapter);
virBufferAsprintf(buf,
- "<address %sbus='%d' target='%d' unit='%d'/>\n",
+ "<address %sbus='%d' target='%d' unit='%lld'/>\n",
includeTypeInAddr ? "type='scsi' " : "",
scsihostsrc->bus, scsihostsrc->target,
scsihostsrc->unit);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ba17a8d..f677c2e 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -463,7 +463,7 @@ struct _virDomainHostdevSubsysSCSIHost {
char *adapter;
unsigned bus;
unsigned target;
- unsigned unit;
+ unsigned long long unit;
};
typedef struct _virDomainHostdevSubsysSCSIiSCSI virDomainHostdevSubsysSCSIiSCSI;
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 0fc59a8..6e0c3a3 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -63,7 +63,7 @@ struct _qemuBuildCommandLineCallbacks {
const char *adapter,
unsigned int bus,
unsigned int target,
- unsigned int unit);
+ unsigned long long unit);
};
extern qemuBuildCommandLineCallbacks buildCommandLineCallbacks;
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 3562de6..bbdf0b0 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1938,7 +1938,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
} else {
virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to prepare scsi hostdev: %s:%d:%d:%d"),
+ _("Unable to prepare scsi hostdev: %s:%d:%d:%lld"),
scsihostsrc->adapter, scsihostsrc->bus,
scsihostsrc->target, scsihostsrc->unit);
}
@@ -3882,7 +3882,7 @@ int qemuDomainDetachHostDevice(virQEMUDriverPtr driver,
virDomainHostdevSubsysSCSIHostPtr scsihostsrc =
&scsisrc->u.host;
virReportError(VIR_ERR_OPERATION_FAILED,
- _("host scsi device %s:%d:%d.%d not found"),
+ _("host scsi device %s:%d:%d:%lld not found"),
scsihostsrc->adapter, scsihostsrc->bus,
scsihostsrc->target, scsihostsrc->unit);
}
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 1c8f31e..e67fe18 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -1482,7 +1482,7 @@ virHostdevReAttachSCSIHostDevices(virHostdevManagerPtr hostdev_mgr,
scsihostsrc->adapter, scsihostsrc->bus,
scsihostsrc->target, scsihostsrc->unit,
hostdev->readonly, hostdev->shareable))) {
- VIR_WARN("Unable to reattach SCSI device %s:%d:%d:%d on domain %s",
+ VIR_WARN("Unable to reattach SCSI device %s:%d:%d:%lld on domain %s",
scsihostsrc->adapter, scsihostsrc->bus, scsihostsrc->target,
scsihostsrc->unit, dom_name);
return;
@@ -1492,7 +1492,7 @@ virHostdevReAttachSCSIHostDevices(virHostdevManagerPtr hostdev_mgr,
* because qemuProcessStart could fail half way through. */
if (!(tmp = virSCSIDeviceListFind(hostdev_mgr->activeSCSIHostdevs, scsi))) {
- VIR_WARN("Unable to find device %s:%d:%d:%d "
+ VIR_WARN("Unable to find device %s:%d:%d:%lld "
"in list of active SCSI devices",
scsihostsrc->adapter, scsihostsrc->bus,
scsihostsrc->target, scsihostsrc->unit);
@@ -1500,7 +1500,7 @@ virHostdevReAttachSCSIHostDevices(virHostdevManagerPtr hostdev_mgr,
return;
}
- VIR_DEBUG("Removing %s:%d:%d:%d dom=%s from activeSCSIHostdevs",
+ VIR_DEBUG("Removing %s:%d:%d:%lld dom=%s from activeSCSIHostdevs",
scsihostsrc->adapter, scsihostsrc->bus, scsihostsrc->target,
scsihostsrc->unit, dom_name);
diff --git a/src/util/virscsi.c b/src/util/virscsi.c
index 9f5cf0d..5fd4380 100644
--- a/src/util/virscsi.c
+++ b/src/util/virscsi.c
@@ -56,7 +56,7 @@ struct _virSCSIDevice {
unsigned int adapter;
unsigned int bus;
unsigned int target;
- unsigned int unit;
+ unsigned long long unit;
char *name; /* adapter:bus:target:unit */
char *id; /* model:vendor */
@@ -110,7 +110,7 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix,
const char *adapter,
unsigned int bus,
unsigned int target,
- unsigned int unit)
+ unsigned long long unit)
{
DIR *dir = NULL;
struct dirent *entry;
@@ -123,7 +123,7 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix,
return NULL;
if (virAsprintf(&path,
- "%s/%d:%d:%d:%d/scsi_generic",
+ "%s/%d:%d:%d:%lld/scsi_generic",
prefix, adapter_id, bus, target, unit) < 0)
return NULL;
@@ -157,7 +157,7 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix,
const char *adapter,
unsigned int bus,
unsigned int target,
- unsigned int unit)
+ unsigned long long unit)
{
DIR *dir = NULL;
struct dirent *entry;
@@ -170,7 +170,7 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix,
return NULL;
if (virAsprintf(&path,
- "%s/%d:%d:%d:%d/block",
+ "%s/%d:%d:%d:%lld/block",
prefix, adapter_id, bus, target, unit) < 0)
return NULL;
@@ -200,7 +200,7 @@ virSCSIDeviceNew(const char *sysfs_prefix,
const char *adapter,
unsigned int bus,
unsigned int target,
- unsigned int unit,
+ unsigned long long unit,
bool readonly,
bool shareable)
{
@@ -227,7 +227,7 @@ virSCSIDeviceNew(const char *sysfs_prefix,
if (virSCSIDeviceGetAdapterId(adapter, &dev->adapter) < 0)
goto cleanup;
- if (virAsprintf(&dev->name, "%d:%d:%d:%d", dev->adapter,
+ if (virAsprintf(&dev->name, "%d:%d:%d:%lld", dev->adapter,
dev->bus, dev->target, dev->unit) < 0 ||
virAsprintf(&dev->sg_path, "%s/%s",
sysfs_prefix ? sysfs_prefix : "/dev", sg) < 0)
@@ -347,7 +347,7 @@ virSCSIDeviceGetTarget(virSCSIDevicePtr dev)
return dev->target;
}
-unsigned int
+unsigned long long
virSCSIDeviceGetUnit(virSCSIDevicePtr dev)
{
return dev->unit;
diff --git a/src/util/virscsi.h b/src/util/virscsi.h
index c67837f..df40d7f 100644
--- a/src/util/virscsi.h
+++ b/src/util/virscsi.h
@@ -37,18 +37,18 @@ char *virSCSIDeviceGetSgName(const char *sysfs_prefix,
const char *adapter,
unsigned int bus,
unsigned int target,
- unsigned int unit);
+ unsigned long long unit);
char *virSCSIDeviceGetDevName(const char *sysfs_prefix,
const char *adapter,
unsigned int bus,
unsigned int target,
- unsigned int unit);
+ unsigned long long unit);
virSCSIDevicePtr virSCSIDeviceNew(const char *sysfs_prefix,
const char *adapter,
unsigned int bus,
unsigned int target,
- unsigned int unit,
+ unsigned long long unit,
bool readonly,
bool shareable);
@@ -61,7 +61,7 @@ const char *virSCSIDeviceGetName(virSCSIDevicePtr dev);
unsigned int virSCSIDeviceGetAdapter(virSCSIDevicePtr dev);
unsigned int virSCSIDeviceGetBus(virSCSIDevicePtr dev);
unsigned int virSCSIDeviceGetTarget(virSCSIDevicePtr dev);
-unsigned int virSCSIDeviceGetUnit(virSCSIDevicePtr dev);
+unsigned long long virSCSIDeviceGetUnit(virSCSIDevicePtr dev);
bool virSCSIDeviceGetReadonly(virSCSIDevicePtr dev);
bool virSCSIDeviceGetShareable(virSCSIDevicePtr dev);
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index d067bca..ceaabb6 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -462,7 +462,7 @@ testSCSIDeviceGetSgName(const char *sysfs_prefix ATTRIBUTE_UNUSED,
const char *adapter ATTRIBUTE_UNUSED,
unsigned int bus ATTRIBUTE_UNUSED,
unsigned int target ATTRIBUTE_UNUSED,
- unsigned int unit ATTRIBUTE_UNUSED)
+ unsigned long long unit ATTRIBUTE_UNUSED)
{
char *sg = NULL;
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 4c47473..aa4d58c 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -415,7 +415,7 @@ struct PCIAddress {
struct SCSIAddress {
unsigned int controller;
unsigned int bus;
- unsigned int unit;
+ unsigned long long unit;
};
struct IDEAddress {
@@ -488,7 +488,7 @@ static int str2SCSIAddress(const char *str, struct SCSIAddress *scsiAddr)
return -1;
unit++;
- if (virStrToLong_ui(unit, NULL, 0, &scsiAddr->unit) != 0)
+ if (virStrToLong_ull(unit, NULL, 0, &scsiAddr->unit) != 0)
return -1;
return 0;
@@ -725,7 +725,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
if (diskAddr.type == DISK_ADDR_TYPE_SCSI) {
virBufferAsprintf(&buf,
"<address type='drive' controller='%d'"
- " bus='%d' unit='%d' />\n",
+ " bus='%d' unit='%lld' />\n",
diskAddr.addr.scsi.controller, diskAddr.addr.scsi.bus,
diskAddr.addr.scsi.unit);
} else {
--
1.9.1
9 years, 5 months
[libvirt] [PATCH 0/2] Adjust netfs CIFS/Samba formatting
by John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1186969
The first patch follows a previous change to fix/adjust the gluster
specific rng formatting
The second patch resolves the particular issue ensuring to generate the
source path with the "//%s/%s" instead of "%s:%s" and with the "-o group"
to connect to the Samba serbver.
John Ferlan (2):
storage: Fix the schema and add tests for cifs pool
storage: Generate correct parameters for CIFS
docs/formatstorage.html.in | 7 ++++--
docs/schemas/storagepool.rng | 24 +++++++++++++++++++-
docs/storage.html.in | 3 ++-
src/storage/storage_backend_fs.c | 29 ++++++++++++++++++++-----
tests/storagepoolxml2xmlin/pool-netfs-cifs.xml | 12 ++++++++++
tests/storagepoolxml2xmlout/pool-netfs-cifs.xml | 15 +++++++++++++
tests/storagepoolxml2xmltest.c | 1 +
7 files changed, 82 insertions(+), 9 deletions(-)
create mode 100644 tests/storagepoolxml2xmlin/pool-netfs-cifs.xml
create mode 100644 tests/storagepoolxml2xmlout/pool-netfs-cifs.xml
--
2.1.0
9 years, 5 months
[libvirt] [PATCH v2] storage: Need to set secrettype for direct iscsi disk volume
by John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1200206
Commit id '1b4eaa61' added the ability to have a mode='direct' for
an iscsi disk volume. It relied on virStorageTranslateDiskSourcePool
in order to copy any disk source pool authentication information to
the direct disk volume, but it neglected to also copy the 'secrettype'
field which ends up being used in the domain volume formatting code.
Adding a secrettype for this case will allow for proper formatting later
and allow disk snapshotting to work properly
Additionally libvirtd restart processing would fail to find the domain
since the translation processing code is run after domain xml processing,
so handle the the case where the authdef could have an empty secrettype
field when processing the auth and additionally ignore performing the
actual and expected auth secret type checks for a DISK_VOLUME since that
data will be reassembled later during translation processing of the
running domain.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
Changes since v1:
- Found that the libvirtd restart path caused issues - my initial attempt
to fix made a bad assumption - that I was running with a domain started
after the initial patch which would have the secrettype filled in by
the translate code.
So this patch changes the domain parse code to better account for the
chance that secrettype isn't yet provided in the XML by having the
authdef processing code fill in the value.
Secondly since the pooltype was only filled during the translation on
libvirtd restart and that occurs after domain xml process, the pooltype
field would be empty - thus it couldn't be used for comparison. Since,
translation processing will destroy the authdef read in at parse time,
modify the actual and expected check to ignore the DISK_VOLUME case
src/conf/domain_conf.c | 16 +++++++++++++++-
src/storage/storage_driver.c | 10 ++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 36de844..d621c01 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6571,6 +6571,16 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
xmlStrEqual(cur->name, BAD_CAST "auth")) {
if (!(authdef = virStorageAuthDefParse(node->doc, cur)))
goto error;
+ /* Shared processing code with storage pools can leave
+ * this empty, but disk formatting uses it as does command
+ * creation - so use the secretType to attempt to fill it in.
+ */
+ if (!authdef->secrettype) {
+ const char *secrettype =
+ virSecretUsageTypeToString(authdef->secretType);
+ if (VIR_STRDUP(authdef->secrettype, secrettype) < 0)
+ goto error;
+ }
if ((auth_secret_usage =
virSecretUsageTypeFromString(authdef->secrettype)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -6790,7 +6800,11 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
cur = cur->next;
}
- if (auth_secret_usage != -1 && auth_secret_usage != expected_secret_usage) {
+ /* Disk volume types will have authentication information handled in
+ * virStorageTranslateDiskSourcePool
+ */
+ if (def->src->type != VIR_STORAGE_TYPE_VOLUME &&
+ auth_secret_usage != -1 && auth_secret_usage != expected_secret_usage) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid secret type '%s'"),
virSecretUsageTypeToString(auth_secret_usage));
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index ab8675d..57060ab 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -3310,6 +3310,16 @@ virStorageTranslateDiskSourcePool(virConnectPtr conn,
&pooldef->source) < 0)
goto cleanup;
+ /* Source pool may not fill in the secrettype field,
+ * so we need to do so here
+ */
+ if (def->src->auth && !def->src->auth->secrettype) {
+ const char *secrettype =
+ virSecretUsageTypeToString(VIR_SECRET_USAGE_TYPE_ISCSI);
+ if (VIR_STRDUP(def->src->auth->secrettype, secrettype) < 0)
+ goto cleanup;
+ }
+
if (virStorageAddISCSIPoolSourceHost(def, pooldef) < 0)
goto cleanup;
break;
--
2.1.0
9 years, 5 months