[libvirt] [PATCH v2] storage: Adjust expected format for Disk startup processing
by John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1464313
If a Disk pool was defined/created using XML that either didn't
specify a specific format or specified format type='unknown', then
restarting a pool after an initial disk backend build with overwrite
would fail after a libvirtd restart for a non-autostarted pool.
This is because the persistent pool data is not updated during pool
build w/ overwrite processing to have the VIR_STORAGE_POOL_DISK_DOS
default format.
So in addition to the alteration done during disk build processing,
alter the default expectation for disk startup to be DOS if nothing
has been defined yet. That will either succeed if the pool had been
successfully built previously using the default DOS format or fail
with a message indicating the format is something else that does not
match the expect format 'dos'.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
v1: https://www.redhat.com/archives/libvir-list/2017-September/msg00124.html
Changes since v1...
* Use a totally different methodology. Rather than updating the
persistent config file, alter the start processing to handle the
unknown setting in the persistent file properly.
src/storage/storage_backend_disk.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index e8f67bb00..bce3b4e2a 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -446,8 +446,7 @@ static int
virStorageBackendDiskStartPool(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr pool)
{
- const char *format =
- virStoragePoolFormatDiskTypeToString(pool->def->source.format);
+ const char *format;
const char *path = pool->def->source.devices[0].path;
virWaitForDevices();
@@ -458,6 +457,9 @@ virStorageBackendDiskStartPool(virConnectPtr conn ATTRIBUTE_UNUSED,
return -1;
}
+ if (pool->def->source.format == VIR_STORAGE_POOL_DISK_UNKNOWN)
+ pool->def->source.format = VIR_STORAGE_POOL_DISK_DOS;
+ format = virStoragePoolFormatDiskTypeToString(pool->def->source.format);
if (!virStorageBackendDeviceIsEmpty(path, format, false))
return -1;
--
2.13.5
7 years, 2 months
[libvirt] [PATCH v2] qemu: Provide default LUN=0 for iSCSI if not provided
by John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1477880
If the "/#" is missing from the provided iSCSI path, then we need
to provide the default LUN of /0; otherwise, QEMU will fail to parse
the URL causing a failure to either create the guest or hotplug
attach the storage.
During post parse, for any iSCSI disk or hostdev, scan the source
path looking for the presence of '/', if found, then we can assume
the LUN is provided. If not found, alter the input XML to add the
"/0". This will cause the generated XML to have the generated
value when the domain config is saved after post parse.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
v1: https://www.redhat.com/archives/libvir-list/2017-September/msg00122.html
Alter the patch to make the adjustment during device post parsing rather
than command line creation as requested by code review. This will alter
the output XML as well as the command line arguments for those entries
that don't supply a LUN. We had a few, so that works out testing wise!
src/conf/domain_conf.c | 43 ++++++++++++++++++++++
.../qemuargv2xml-disk-drive-network-iscsi.xml | 2 +-
.../qemuxml2argv-disk-drive-network-iscsi-lun.args | 2 +-
.../qemuxml2argv-disk-drive-network-iscsi.args | 2 +-
.../qemuxml2argv-hostdev-scsi-lsi-iscsi.args | 2 +-
.../qemuxml2argv-hostdev-scsi-virtio-iscsi.args | 2 +-
.../qemuxml2xmlout-disk-drive-network-iscsi.xml | 2 +-
.../qemuxml2xmlout-hostdev-scsi-lsi-iscsi.xml | 2 +-
.../qemuxml2xmlout-hostdev-scsi-virtio-iscsi.xml | 2 +-
9 files changed, 51 insertions(+), 8 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 676fc0f34..a43b25c31 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4308,16 +4308,54 @@ virDomainHostdevAssignAddress(virDomainXMLOptionPtr xmlopt,
}
+/**
+ * virDomainPostParseCheckISCSIPath
+ * @srcpath: Source path read (a/k/a, IQN) either disk or hostdev
+ *
+ * The details of an IQN is defined by RFC 3720 and 3721, but
+ * we just need to make sure there's a lun provided. If not
+ * provided, then default to zero. For an ISCSI LUN that is
+ * is provided by /dev/disk/by-path/... , then that path will
+ * have the specific lun requested.
+ *
+ * Returns 0 on success, -1 on failure
+ */
+static int
+virDomainPostParseCheckISCSIPath(char **srcpath)
+{
+ char *path = NULL;
+
+ if (strchr(*srcpath, '/'))
+ return 0;
+
+ if (virAsprintf(&path, "%s/0", *srcpath) < 0)
+ return -1;
+ VIR_FREE(*srcpath);
+ VIR_STEAL_PTR(*srcpath, path);
+ return 0;
+}
+
+
static int
virDomainHostdevDefPostParse(virDomainHostdevDefPtr dev,
const virDomainDef *def,
virDomainXMLOptionPtr xmlopt)
{
+ virDomainHostdevSubsysSCSIPtr scsisrc;
+
if (dev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
return 0;
switch (dev->source.subsys.type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
+ scsisrc = &dev->source.subsys.u.scsi;
+ if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
+ virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
+
+ if (virDomainPostParseCheckISCSIPath(&iscsisrc->path) < 0)
+ return -1;
+ }
+
if (dev->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
virDomainHostdevAssignAddress(xmlopt, def, dev) < 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -4455,6 +4493,11 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDefPtr dev,
}
}
+ if (disk->src->type == VIR_STORAGE_TYPE_NETWORK &&
+ disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_ISCSI &&
+ virDomainPostParseCheckISCSIPath(&disk->src->path) < 0)
+ return -1;
+
if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO &&
virDomainCheckVirtioOptions(disk->virtio) < 0)
return -1;
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.xml b/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.xml
index 23542fa1d..694412b5c 100644
--- a/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.xml
+++ b/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.xml
@@ -16,7 +16,7 @@
<emulator>/usr/bin/qemu-system-i686</emulator>
<disk type='network' device='disk'>
<driver name='qemu' type='raw'/>
- <source protocol='iscsi' name='iqn.1992-01.com.example'>
+ <source protocol='iscsi' name='iqn.1992-01.com.example/0'>
<host name='example.org' port='6000'/>
</source>
<target dev='vda' bus='virtio'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-lun.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-lun.args
index b25f3a0d6..0fbfd9a6d 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-lun.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-lun.args
@@ -21,7 +21,7 @@ server,nowait \
-boot c \
-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 \
-usb \
--drive file=iscsi://example.org:3260/iqn.1992-01.com.example,format=raw,\
+-drive file=iscsi://example.org:3260/iqn.1992-01.com.example/0,format=raw,\
if=none,id=drive-scsi0-0-0-0 \
-device scsi-block,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\
drive=drive-scsi0-0-0-0,id=scsi0-0-0-0
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi.args
index a1d93af10..ed15fda21 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi.args
@@ -19,7 +19,7 @@ server,nowait \
-no-acpi \
-boot c \
-usb \
--drive file=iscsi://example.org:6000/iqn.1992-01.com.example,format=raw,\
+-drive file=iscsi://example.org:6000/iqn.1992-01.com.example/0,format=raw,\
if=none,id=drive-virtio-disk0 \
-device virtio-blk-pci,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\
id=virtio-disk0 \
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args
index 43c555a50..07ae9f592 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args
@@ -22,7 +22,7 @@ server,nowait \
-usb \
-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-0-0 \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
--drive file=iscsi://example.org:3260/iqn.1992-01.com.example,if=none,\
+-drive file=iscsi://example.org:3260/iqn.1992-01.com.example/0,if=none,\
format=raw,id=drive-hostdev0 \
-device scsi-generic,bus=scsi0.0,scsi-id=4,drive=drive-hostdev0,id=hostdev0 \
-drive file=iscsi://example.org:3260/iqn.1992-01.com.example/1,if=none,\
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args
index a78e3092c..d80c85918 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args
@@ -22,7 +22,7 @@ server,nowait \
-usb \
-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-0-0 \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
--drive file=iscsi://example.org:3260/iqn.1992-01.com.example,if=none,\
+-drive file=iscsi://example.org:3260/iqn.1992-01.com.example/0,if=none,\
format=raw,id=drive-hostdev0 \
-device scsi-generic,bus=scsi0.0,channel=0,scsi-id=2,lun=4,\
drive=drive-hostdev0,id=hostdev0 \
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-iscsi.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-iscsi.xml
index 23542fa1d..694412b5c 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-iscsi.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-iscsi.xml
@@ -16,7 +16,7 @@
<emulator>/usr/bin/qemu-system-i686</emulator>
<disk type='network' device='disk'>
<driver name='qemu' type='raw'/>
- <source protocol='iscsi' name='iqn.1992-01.com.example'>
+ <source protocol='iscsi' name='iqn.1992-01.com.example/0'>
<host name='example.org' port='6000'/>
</source>
<target dev='vda' bus='virtio'/>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-lsi-iscsi.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-lsi-iscsi.xml
index e19bce6ea..b7312ca4f 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-lsi-iscsi.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-lsi-iscsi.xml
@@ -32,7 +32,7 @@
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<hostdev mode='subsystem' type='scsi' managed='yes'>
- <source protocol='iscsi' name='iqn.1992-01.com.example'>
+ <source protocol='iscsi' name='iqn.1992-01.com.example/0'>
<host name='example.org' port='3260'/>
</source>
<address type='drive' controller='0' bus='0' target='0' unit='4'/>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-virtio-iscsi.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-virtio-iscsi.xml
index 37635b4f9..ddf780160 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-virtio-iscsi.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-virtio-iscsi.xml
@@ -32,7 +32,7 @@
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<hostdev mode='subsystem' type='scsi' managed='yes'>
- <source protocol='iscsi' name='iqn.1992-01.com.example'>
+ <source protocol='iscsi' name='iqn.1992-01.com.example/0'>
<host name='example.org' port='3260'/>
</source>
<address type='drive' controller='0' bus='0' target='2' unit='4'/>
--
2.13.5
7 years, 2 months
[libvirt] Yet another RFC for CAT
by Martin Kletzander
Hello everyone.
Last couple of weeks [1] I was working on CAT for libvirt. Only
clean-ups and minor things were pushed into upstream, but as I'm getting
closer and closer to actual functionality I'm seeing a problem with our
current (already discussed and approved) design. And I would like to
know your thoughts about this, even if you are not familiar with CAT,
feel free to keep the questions coming.
* Little bit of background about CAT
[I wanted to say "Long story short...", but after reading the mail in
its entirety before sending it I see it would end up like in "I Should
Have Never Gone Ziplining", so I'll rather let you brace for quite
elongated or, dare I say, endless stream of words]
Since the interface for CAT in the Linux kernel is quite hairy (together
with cache information reporting, don't even get me started on that) and
might feel pretty inconsistent if you are used to any Linux kernel
interface, I would like to summarize how is it used [2]. Feel free to
skip this part if you are familiar with it.
You can tune how much cache which processes can utilize. Let's talk
only about L3 for now, also let's assume only unified caches (no
code/data prioritization). For simplicity.
The cache is split into parts and when describing the allocation we use
hexadecimal representation of bit masks where each bit is the smallest
addressable (or rather allocable) part of the cache. Let's say you have
16MB L3 cache which the CPU is able to allocate by chunks of 1MB, so the
allocation is represented by 32 bits => 8 hexadecimal characters. Yes,
there can be minimum of continuous bits that need to be specified, you
can have multiple L3 caches, etc., but that's yet another thing that's
not important to what I need to discuss. The whole cache is then
referred to as "ffff" in this particular case. Again, for simplicity
sake, let's assume the above hardware is constant in future examples.
Now, when you want to work with the allocations, it behaves similarly
(not the same way, though) as cgroups. The default group, which
contains all processes, is in /sys/fs/resctrl, and you can create
additional groups (directories under /sys/fs/resctrl). These are flat,
not hierarchical, meaning they cannot have subdirectories. Each
resource group represents a group of processes (PIDs are written in
"tasks" file) that share the same resource settings. One of the
settings is the allocation of caches. By default there are no
additional resource groups (subdirectories of /sys/fs/resctrl) and the
default one occupies all the cache.
(IIRC, all bit masks must have only consecutive bits, but I cannot find
this in the documentation; let's assume this as well, but feel free to
correct me)
* Example time (we're almost there)
Let's say you have the default group with this setting:
L3:0=00ff
That is setting of allocation for L3 cache, both code and data, cache id
0 and the occupancy rate is 50% (lower 8MB of the only L3 cache in our
example to be precise).
If you now create additional resource group, let's say
"libvirt-qemu-3-alpine-vcpu3" (truly random name, right?) and set the
following allocation:
L3:0=0ff0
That specifies it will be allowed to use also 8MB of the cache, but this
time from the middle. Half of that will be shared between this group
and the default one, the rest is exclusive to this group only.
* The current design (finally something libvirt-related, right?)
The discussion ended with a conclusion of the following (with my best
knowledge, there were so many discussions about so many things that I
would spend too much time looking up all of them):
- Users should not need to specify bit masks, such complexity should be
abstracted. We'll use sizes (e.g. 4MB)
- Multiple vCPUs might need to share the same allocation.
- Exclusivity of allocations is to be assumed, that is only unoccupied
cache should be used for new allocations.
The last point seems trivial but it's actually very specific condition
that, if removed, can cause several problems. If it's hard to grasp the
last point together with the second one, you're on the right track. If
not, then I'll try to make a point for why the last point should be
removed in 3... 2... 1...
* Design flaws
1) Users cannot specify any allocation that would share only part with
some other allocation of the domain or the default group.
2) It was not specified what to do with the default resource group.
There might be several ways to approach this, with varying pros and
cons:
a) Treat it as any other group. That is any bit set for this group
will be excluded from usable bits when creating new allocation
for a domain.
- Very predictable behaviour
- You will not be able to allocate any amount of cache without
previous setting for the default group as that will have all
the bits set which will make all the cache unusable
b) Automatically remove the appropriate amount of bits that are
needed for new domains.
- No need to do any change to the system settings in order to
use this new feature
- We would have to change system settings, which is generally
frowned upon when done "automatically" as a side effect of
starting a domain, especially for such scarce resource as
cache
- The change to system settings would not be entirely
predictable
c) Act like it doesn't exist and don't remove its allocations from
consideration
- Doesn't really make sense as system processes might be
trashing the cache as any VM, moreover when all VM processes
without allocations will be based in the default group as
well
3) There is no way for users to know what the particular settings are
for any running domain.
The first point was deemed a corner case. Fair enough on its own, but
considering point 2 and its solutions, it is rather difficult for me to
justify it. Also, let's say you have domain with 4 vCPUs out of which
you know 1 might be trashing the cache, but you don't want to restrict
it completely, but others will utilize it very nicely. Sensible
allocations for such domain's vCPUs might be:
vCPU 0: 000f
vCPUs 1-3: ffff
as you want vCPUs 1-3 to utilize even the part of cache that might get
trashed by vCPU 0. Or they might share some data (especially
guest-memory-related).
The case above is not possible to set up with only per-vcpu(s) scalar
setting. And there are more as you might imagine now. For example how
do we behave with iothreads and emulator threads?
* My suggestion:
- Provide an API for querying and changing the allocation of the
default resource group. This would be similar to setting and
querying hugepage allocations (see virsh's freepages/allocpages
commands).
- Let users specify the starting position in addition to the size, i.e.
not only specifying "size", but also "from". If "from" is not
specified, the whole allocation must be exclusive. If "from" is
specified it will be set without checking for collisions. The latter
needs them to query the system or know what settings are applied
(this should be the case all the time), but is better then adding
non-specific and/or meaningless exclusivity settings (how do you
specify part-exclusivity of the cache as in the example above)
- After starting a domain, fill in any missing information about the
allocation (I'm generalizing here, but fro now it would only be the
optional "from" attribute)
- Add settings not only for vCPUs, but also for other threads as we do
with pinning, schedulers, etc.
Let me know what you think. As I said before, even if you're not
familiar with CAT. And thank you for reading the whole thing or at
least skipping to the end. I spend quite some time on this, I changed
the underlying code design several times (thanks again for the
"consistency" of the design of resctrlfs) and I'm afraid my head is
going to burst any moment now.
Have a nice day
Martin
P.S.: I still continue on the implementation, you can follow it on my
github [3]. Don't expect the tests to pass or all functions to be
complete, thought. You have been warned.
[1] Technically months, I can't wrap my head around how much technical
debt there is in libvirt.
[2] Detailed information in Documentation/x86/intel_rdt_ui.txt
[3] https://github.com/nertpinx/libvirt/tree/catwip
7 years, 2 months
[libvirt] [PATCH] qemu: handle reconnect on chardev hotplug
by ZhiPeng Lu
The patch passes the reconnect timeout to QEMU by monitor on chardev hotplug.
Signed-off-by: ZhiPeng Lu <lu.zhipeng(a)zte.com.cn>
---
src/qemu/qemu_monitor_json.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index df5fb7c..4169cd5 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6444,6 +6444,17 @@ int qemuMonitorJSONGetTPMTypes(qemuMonitorPtr mon,
return qemuMonitorJSONGetStringArray(mon, "query-tpm-types", tpmtypes);
}
+static int
+qemuMonitorJSONBuildChrChardevReconnect(virJSONValuePtr object,
+ const virDomainChrSourceReconnectDef *def)
+{
+ int ret = 0;
+ if (def->enabled == VIR_TRISTATE_BOOL_YES) {
+ ret = virJSONValueObjectAppendNumberUint(object, "reconnect", def->timeout);
+ }
+ return ret;
+}
+
static virJSONValuePtr
qemuMonitorJSONAttachCharDevCommand(const char *chrID,
const virDomainChrSourceDef *chr)
@@ -6508,6 +6519,10 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
if (virJSONValueObjectAppendString(data, "tls-creds", tlsalias) < 0)
goto cleanup;
}
+
+ if (qemuMonitorJSONBuildChrChardevReconnect(data, &chr->data.tcp.reconnect) < 0) {
+ goto cleanup;
+ }
break;
case VIR_DOMAIN_CHR_TYPE_UDP:
@@ -6545,6 +6560,10 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
if (virJSONValueObjectAppendBoolean(data, "wait", false) < 0 ||
virJSONValueObjectAppendBoolean(data, "server", chr->data.nix.listen) < 0)
goto cleanup;
+
+ if (qemuMonitorJSONBuildChrChardevReconnect(data, &chr->data.nix.reconnect) < 0) {
+ goto cleanup;
+ }
break;
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
--
1.8.3.1
7 years, 2 months
[libvirt] [PATCH] storage: Check and possibly update config file after build
by John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1464313
As it turns out, the on-disk config file (e.g. not the stateDir file)
needs to be updated when --override is provided since it's possible and
highly probable that the def->source.format has been adjusted and could
cause a future start after perhaps a libvirtd restart to have the older
format from a define operation from the backend.
So in the 2 places where it's possible a write would be needed (create
after define and build), let's perform a check and do the save/write
operation on the configFile if it's necessary.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/storage/storage_driver.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 7cf5943..afb0404 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -651,6 +651,22 @@ storagePoolIsPersistent(virStoragePoolPtr pool)
}
+/* After a pool build, it's possible the inactive configFile needs to
+ * be updated especially since overwriting the pool more than likely
+ * changes the source format and may change/update a few other fields. */
+static int
+storagePoolBuildCheckUpdateConfig(virStoragePoolObjPtr obj,
+ unsigned int flags)
+{
+ int ret = 0;
+
+ if ((flags & VIR_STORAGE_POOL_BUILD_OVERWRITE) && obj->configFile)
+ ret = virStoragePoolSaveConfig(obj->configFile, obj->def);
+
+ return ret;
+}
+
+
static virStoragePoolPtr
storagePoolCreateXML(virConnectPtr conn,
const char *xml,
@@ -916,6 +932,9 @@ storagePoolCreate(virStoragePoolPtr pool,
if (backend->buildPool(pool->conn, obj, build_flags) < 0)
goto cleanup;
}
+
+ if (storagePoolBuildCheckUpdateConfig(obj, build_flags) < 0)
+ goto cleanup;
}
VIR_INFO("Starting up storage pool '%s'", obj->def->name);
@@ -980,6 +999,10 @@ storagePoolBuild(virStoragePoolPtr pool,
if (backend->buildPool &&
backend->buildPool(pool->conn, obj, flags) < 0)
goto cleanup;
+
+ if (storagePoolBuildCheckUpdateConfig(obj, flags) < 0)
+ goto cleanup;
+
ret = 0;
cleanup:
--
2.9.5
7 years, 2 months
[libvirt] [PATCH 0/3] typo fixes
by Guido Günther
Probably could have gone by the trivial rule.
Guido Günther (3):
storagefile: fix defintion vs definition typo
qemu_driver: fix existance vs existence typo
virnetserver: fix mesage vs message typo
src/qemu/qemu_driver.c | 2 +-
src/rpc/virnetserver.c | 2 +-
src/util/virstoragefile.c | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
--
2.14.1
7 years, 2 months
[libvirt] [PATCH] qemu: Provide default LUN=0 for iSCSI if not provided
by John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1477880
If the "/#" is missing from the provided iSCSI path, then we need
to provide the default LUN of /0; otherwise, QEMU will fail to parse
the URL causing a failure to either create the guest or hotplug
attach the storage.
Alter the command lines generated appropriately. This change does not
effect the XML input files.
One 'side effect' of this for the argv2xml is that if a "/0" is found
on the command line, then the generated XML would need to add the "/0"
to the output XML since it wouldn't be known whether it existed or not
at qemu process creation time.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
NB: Investigated the history quite a bit between QEMU and libiscsi and
it seems as though this probably never worked and of course never "tested"
in a real environment. Ironically, in qapi/block-core.json, it is claimed
that the LUN would default to 0, but the block/iscsi.c code that calls
iscsi_parse_full_url would never (AFAICT) have supported not supplying
some LUN on the command line.
src/qemu/qemu_command.c | 20 ++++++++++++++++----
.../qemuargv2xml-disk-drive-network-iscsi.args | 2 +-
.../qemuargv2xml-disk-drive-network-iscsi.xml | 2 +-
.../qemuxml2argv-disk-drive-network-iscsi-lun.args | 2 +-
.../qemuxml2argv-disk-drive-network-iscsi.args | 2 +-
.../qemuxml2argv-hostdev-scsi-lsi-iscsi.args | 2 +-
.../qemuxml2argv-hostdev-scsi-virtio-iscsi.args | 2 +-
7 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index ed8cb6e..cff84de 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -830,10 +830,22 @@ qemuBuildNetworkDriveURI(virStorageSourcePtr src,
src->volume, src->path) < 0)
goto cleanup;
} else {
- if (virAsprintf(&uri->path, "%s%s",
- src->path[0] == '/' ? "" : "/",
- src->path) < 0)
- goto cleanup;
+ if (src->protocol == VIR_STORAGE_NET_PROTOCOL_ISCSI &&
+ !strchr(src->path, '/')) {
+
+ /* The details of iqn is defined by RFC 3720 and 3721, but
+ * we just need to make sure there's a lun provided. If not
+ * provided, then default to zero. If ISCSI LUN is provided
+ * by /dev/disk/by-path/... , then that path will have the
+ * specific lun requested. */
+ if (virAsprintf(&uri->path, "/%s/0", src->path) < 0)
+ goto cleanup;
+ } else {
+ if (virAsprintf(&uri->path, "%s%s",
+ src->path[0] == '/' ? "" : "/",
+ src->path) < 0)
+ goto cleanup;
+ }
}
}
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.args b/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.args
index 62cc5c0..ec2e8dc 100644
--- a/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.args
+++ b/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.args
@@ -16,7 +16,7 @@ QEMU_AUDIO_DRV=none \
-no-acpi \
-boot c \
-usb \
--drive file=iscsi://example.org:6000/iqn.1992-01.com.example,format=raw,\
+-drive file=iscsi://example.org:6000/iqn.1992-01.com.example/0,format=raw,\
if=virtio \
-drive file=iscsi://example.org:6000/iqn.1992-01.com.example/1,format=raw,\
if=virtio \
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.xml b/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.xml
index 23542fa..694412b 100644
--- a/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.xml
+++ b/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.xml
@@ -16,7 +16,7 @@
<emulator>/usr/bin/qemu-system-i686</emulator>
<disk type='network' device='disk'>
<driver name='qemu' type='raw'/>
- <source protocol='iscsi' name='iqn.1992-01.com.example'>
+ <source protocol='iscsi' name='iqn.1992-01.com.example/0'>
<host name='example.org' port='6000'/>
</source>
<target dev='vda' bus='virtio'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-lun.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-lun.args
index b25f3a0..0fbfd9a 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-lun.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-lun.args
@@ -21,7 +21,7 @@ server,nowait \
-boot c \
-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 \
-usb \
--drive file=iscsi://example.org:3260/iqn.1992-01.com.example,format=raw,\
+-drive file=iscsi://example.org:3260/iqn.1992-01.com.example/0,format=raw,\
if=none,id=drive-scsi0-0-0-0 \
-device scsi-block,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\
drive=drive-scsi0-0-0-0,id=scsi0-0-0-0
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi.args
index a1d93af..ed15fda 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi.args
@@ -19,7 +19,7 @@ server,nowait \
-no-acpi \
-boot c \
-usb \
--drive file=iscsi://example.org:6000/iqn.1992-01.com.example,format=raw,\
+-drive file=iscsi://example.org:6000/iqn.1992-01.com.example/0,format=raw,\
if=none,id=drive-virtio-disk0 \
-device virtio-blk-pci,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\
id=virtio-disk0 \
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args
index 43c555a..07ae9f5 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args
@@ -22,7 +22,7 @@ server,nowait \
-usb \
-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-0-0 \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
--drive file=iscsi://example.org:3260/iqn.1992-01.com.example,if=none,\
+-drive file=iscsi://example.org:3260/iqn.1992-01.com.example/0,if=none,\
format=raw,id=drive-hostdev0 \
-device scsi-generic,bus=scsi0.0,scsi-id=4,drive=drive-hostdev0,id=hostdev0 \
-drive file=iscsi://example.org:3260/iqn.1992-01.com.example/1,if=none,\
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args
index a78e309..d80c859 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args
@@ -22,7 +22,7 @@ server,nowait \
-usb \
-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-0-0 \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
--drive file=iscsi://example.org:3260/iqn.1992-01.com.example,if=none,\
+-drive file=iscsi://example.org:3260/iqn.1992-01.com.example/0,if=none,\
format=raw,id=drive-hostdev0 \
-device scsi-generic,bus=scsi0.0,channel=0,scsi-id=2,lun=4,\
drive=drive-hostdev0,id=hostdev0 \
--
2.9.5
7 years, 2 months
[libvirt] [PATCH] virsh: delete "id" for domrename OPTIONS
by Yanqiu Zhang
"domrename" is used to rename an inactive domain, should not use
id for the --domain OPTION.
---
tools/virsh-domain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index f235c66..84c8dcc 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -10151,7 +10151,7 @@ static const vshCmdInfo info_domrename[] = {
};
static const vshCmdOptDef opts_domrename[] = {
- VIRSH_COMMON_OPT_DOMAIN_FULL,
+ VIRSH_COMMON_OPT_DOMAIN(N_("domain name or uuid")),
{.name = "new-name",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
--
1.8.3.1
7 years, 2 months
[libvirt] [PATCH] qemu: Don't report failure to destroy a destroyed domain
by Jiri Denemark
When destroying a domain libvirt marks it internally with a
beingDestroyed flag to make sure the qemuDomainDestroyFlags API itself
cleans up after the domain rather than letting an uninformed EOF handler
do it. However, when the domain is being started at the moment libvirt
was asked to destroy it, only the starting thread can properly clean up
after the domain and thus it ignores the beingDestroyed flag. Once
qemuDomainDestroyFlags finally gets a job, the domain may not be running
anymore, which should not be reported as an error if the domain has been
starting up.
https://bugzilla.redhat.com/show_bug.cgi?id=1445600
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_driver.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6255d89310..a25daae866 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2224,6 +2224,9 @@ qemuDomainDestroyFlags(virDomainPtr dom,
virObjectEventPtr event = NULL;
qemuDomainObjPrivatePtr priv;
unsigned int stopFlags = 0;
+ int state;
+ int reason;
+ bool starting;
virCheckFlags(VIR_DOMAIN_DESTROY_GRACEFUL, -1);
@@ -2235,13 +2238,29 @@ qemuDomainDestroyFlags(virDomainPtr dom,
if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
+ if (!virDomainObjIsActive(vm)) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto cleanup;
+ }
+
+ state = virDomainObjGetState(vm, &reason);
+ starting = (state == VIR_DOMAIN_PAUSED &&
+ reason == VIR_DOMAIN_PAUSED_STARTING_UP &&
+ !priv->beingDestroyed);
+
if (qemuProcessBeginStopJob(driver, vm, QEMU_JOB_DESTROY,
!(flags & VIR_DOMAIN_DESTROY_GRACEFUL)) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm)) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("domain is not running"));
+ if (starting) {
+ VIR_DEBUG("Domain %s is not running anymore", vm->def->name);
+ ret = 0;
+ } else {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ }
goto endjob;
}
--
2.14.1
7 years, 2 months