Hello all,
I am attempting to use the 'virsh attach-device' command to add storage to a guest
from a pre-defined iSCSI-based storage pool. My desire is to attach a volume from the
storage pool and have the storage pool recognize that the volume is in use and either flag
it as such, or remove it from the pool so that subsequent queries to the pool will only
return available storage volumes. The end goal is to have an automated system use the
libvirt API assign storage volumes to new and existing guests on demand. I guess my first
question is: Is this possible? Does libvirt give any indication that a storage volume
within a pool is available or already in use? I would prefer to avoid having to externally
manage this sort of thing if I can.
I am using Debian Wheezy for the Dom0 and iSCSI SAN (identical setup), along with libvirt
1.0.5-2 from the experimental branch. I have Xen 4.1.4-3+deb7u1 installed, along with its
accompanying packages. All of this is currently running under VirtualBox, but that is only
for my testing/development purposes. I am able to get the Dom0 to recognize the SAN, and
add the storage pool. When I attempt to use 'virsh attach-device', I get the
following error: "error: Failed to attach device from device.xml \ error: POST
operation failed: xend_post: error from xen daemon: (xend.err 'Block device must have
physical details specified')".
I have tracked this specific error down to the Xen python blkif.py, located under
/usr/lib/xen-4.1/lib/python/xen/xend/server/blkif.py for my installation. After reading
through the source, I found that under the getDeviceDetails def there is a non-existent
configuration called 'uname' that is undefined. Looking deeper into the code,
under the getDeviceConfiguration def, I see that the code is trying to read from the
backend configuration, and expecting to see a 'type' and 'params' to use
for setting the aforementioned 'uname' value. This is where I hit the wall, so to
speak.
After reading through the XML documentation for libvirt
(
http://libvirt.org/formatdomain.html#elementsDisks), I see nothing that I can further add
to my XML description that would make sense for adding a volume from a storage pool. For
kicks and giggles, I've tried using the disk type 'carom', which gets me past
the failing python condition, but then gives me the following error when trying to do
anything – in this case, just a simple dumpxml on the domain – with the guest through
virsh: "error: internal error domain information incomplete, vbd has no src".
Subsequently, if I try to call 'detach-device', I get the same error, leaving me
with no other alternative but to destroy/undefine, and recreate the domain using
define/start.
I am able to ssh into the guest after the call to 'attach-device', but no device
is present nor registered (as seen with dmesg). If I reboot the guest libvirt reports that
the guest is "idle", but I cannot console into it due to the error mentioned in
the previous paragraph. I can, however, use 'xm console <guest>' and gain
access that way.
Any and all advice that you can give would be greatly appreciated. I will do everything
that I can to assist as far as trying all suggestions and following directions. :)
Storage Pool XML:
<pool type="iscsi">
<name>virtimages</name>
<source>
<host name="hv02.kstanley.vm"/>
<device path="iqn.2013-05.vm.kstanley.hv02:vdisks"/>
</source>
<target>
<path>/dev/disk/by-path</path>
</target>
</pool>
Device XML:
<disk type="volume" device="disk">
<source pool="virtimages" volume="unit:0:0:1"/>
<target dev="xvdb" bus="virtio"/>
</disk>
Regards,
Ken Stanley