From nobody Wed Feb 11 13:09:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1486497055307544.0757040031598; Tue, 7 Feb 2017 11:50:55 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v17JlVbl046011; Tue, 7 Feb 2017 14:47:31 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v17JkaYk025409 for ; Tue, 7 Feb 2017 14:46:36 -0500 Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v17JkadY027551 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 7 Feb 2017 14:46:36 -0500 Received: from smtp2.provo.novell.com (smtp2.provo.novell.com [137.65.250.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DF70D81254 for ; Tue, 7 Feb 2017 19:46:35 +0000 (UTC) Received: from linux-tbji.provo.novell.com (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (NOT encrypted); Tue, 07 Feb 2017 12:46:33 -0700 From: Jim Fehlig To: libvir-list@redhat.com Date: Tue, 7 Feb 2017 12:46:23 -0700 Message-Id: <20170207194624.25043-2-jfehlig@suse.com> In-Reply-To: <20170207194624.25043-1-jfehlig@suse.com> References: <20170207194624.25043-1-jfehlig@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 200 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 07 Feb 2017 19:46:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 07 Feb 2017 19:46:36 +0000 (UTC) for IP:'137.65.250.81' DOMAIN:'smtp2.provo.novell.com' HELO:'smtp2.provo.novell.com' FROM:'jfehlig@suse.com' RCPT:'' X-RedHat-Spam-Score: -1.501 (BAYES_50, RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.81 smtp2.provo.novell.com 137.65.250.81 smtp2.provo.novell.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH V2 1/2] libxl: set default disk format in device post-parse X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When starting a domian, a libxl_domain_config object is created from virDomainDef. Any virDomainDiskDef devices with a format of VIR_STORAGE_FILE_NONE are mapped to LIBXL_DISK_FORMAT_RAW in the corresponding libxl_disk_device, but the virDomainDiskDef format is never updated to reflect the change. A better place to set a default format for disk devices is the device post-parse callback, ensuring the virDomainDiskDef object reflects the default format. Signed-off-by: Jim Fehlig --- src/libxl/libxl_conf.c | 10 ++-------- src/libxl/libxl_domain.c | 7 ++++++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index b5186f2..da63105 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -765,8 +765,6 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_= disk *x_disk) x_disk->format =3D LIBXL_DISK_FORMAT_VHD; x_disk->backend =3D LIBXL_DISK_BACKEND_TAP; break; - case VIR_STORAGE_FILE_NONE: - /* No subtype specified, default to raw/tap */ case VIR_STORAGE_FILE_RAW: x_disk->format =3D LIBXL_DISK_FORMAT_RAW; x_disk->backend =3D LIBXL_DISK_BACKEND_TAP; @@ -802,8 +800,6 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_= disk *x_disk) case VIR_STORAGE_FILE_VHD: x_disk->format =3D LIBXL_DISK_FORMAT_VHD; break; - case VIR_STORAGE_FILE_NONE: - /* No subtype specified, default to raw */ case VIR_STORAGE_FILE_RAW: x_disk->format =3D LIBXL_DISK_FORMAT_RAW; break; @@ -816,8 +812,7 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_= disk *x_disk) return -1; } } else if (STREQ(driver, "file")) { - if (format !=3D VIR_STORAGE_FILE_NONE && - format !=3D VIR_STORAGE_FILE_RAW) { + if (format !=3D VIR_STORAGE_FILE_RAW) { virReportError(VIR_ERR_INTERNAL_ERROR, _("libxenlight does not support disk format= %s " "with disk driver %s"), @@ -828,8 +823,7 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_= disk *x_disk) x_disk->format =3D LIBXL_DISK_FORMAT_RAW; x_disk->backend =3D LIBXL_DISK_BACKEND_QDISK; } else if (STREQ(driver, "phy")) { - if (format !=3D VIR_STORAGE_FILE_NONE && - format !=3D VIR_STORAGE_FILE_RAW) { + if (format !=3D VIR_STORAGE_FILE_RAW) { virReportError(VIR_ERR_INTERNAL_ERROR, _("libxenlight does not support disk format= %s " "with disk driver %s"), diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index ed73cd2..c0ace33 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -362,16 +362,21 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr d= ev, } } =20 - /* for network-based disks, set 'qemu' as the default driver */ if (dev->type =3D=3D VIR_DOMAIN_DEVICE_DISK) { virDomainDiskDefPtr disk =3D dev->data.disk; int actual_type =3D virStorageSourceGetActualType(disk->src); + int format =3D virDomainDiskGetFormat(disk); =20 + /* for network-based disks, set 'qemu' as the default driver */ if (actual_type =3D=3D VIR_STORAGE_TYPE_NETWORK) { if (!virDomainDiskGetDriver(disk) && virDomainDiskSetDriver(disk, "qemu") < 0) return -1; } + + /* xl.cfg default format is raw. See xl-disk-configuration(5) */ + if (format =3D=3D VIR_STORAGE_FILE_NONE) + virDomainDiskSetFormat(disk, VIR_STORAGE_FILE_RAW); } =20 return 0; --=20 2.9.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list