
On 02/07/2017 08:30 AM, Jim Fehlig wrote:
On 02/07/2017 03:26 AM, Michal Privoznik wrote:
On 02/06/2017 11:08 PM, Jim Fehlig wrote:
When a user does not explicitly set a <driver> in the disk config, libvirt defers selection of a default to libxl. This approach works fine when starting a domain with such configuration or attaching a disk to a running domain. But when detaching such a disk, libxl will fail with "unrecognized disk backend type: 0". libxl makes no attempt to recalculate a default backend (driver) on detach and simply fails when uninitialized.
This patch updates the libvirt disk config with the backend selected by libxl when starting a domain or attaching a disk to a running domain. Another benefit of this approach is that the live XML is also updated with the backend driver selected by libxl.
Signed-off-by: Jim Fehlig <jfehlig@suse.com> --- src/libxl/libxl_conf.c | 33 +++++++++++++++++++++++++++++++++ src/libxl/libxl_conf.h | 4 ++++ src/libxl/libxl_domain.c | 25 +++++++++++++++++++++++++ src/libxl/libxl_driver.c | 2 +- 4 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index b5186f2..6ef7570 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -851,6 +851,7 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk) * xl-disk-configuration.txt in the xen documentation and let * libxl pick a suitable backend. */ + virDomainDiskSetFormat(l_disk, VIR_STORAGE_FILE_RAW); x_disk->format = LIBXL_DISK_FORMAT_RAW; x_disk->backend = LIBXL_DISK_BACKEND_UNKNOWN;
This doesn't feel right. I know what do you want it here for, but this function is meant to take 'const' disk definition and translate it to libxl definition. Although, I don't have a better suggestion where to put it.
How about in the UpdateDisk function introduced in this patch? E.g. update it to raw if current format is VIR_STORAGE_FILE_NONE?
After thinking about it some more, seems the best place to set the default when format is VIR_STORAGE_FILE_NONE is in the device post-parse callback. I've sent a V2 along those lines https://www.redhat.com/archives/libvir-list/2017-February/msg00248.html Regards, Jim