[libvirt] [PATCH 2/3 v2] vz: allow to boot VM from cdrom
Dmitry Guryanov
dguryanov at virtuozzo.com
Tue Dec 22 15:31:33 UTC 2015
On Tue, 2015-12-15 at 14:43 +0300, Mikhail Feoktistov wrote:
> If user creates virtual machine via virt-manager and select "boot from ISO"
> then in libvirt we can see the following devices section
>
> <disk type="file" device="disk">
> <source file="/var/lib/libvirt/images/generic.img"/>
> <target dev="hda" bus="ide"/>
> </disk>
> <disk type="file" device="cdrom">
> <source file="/var/lib/libvirt/images/Fedora-Live-Xfce-x86_64-23-10.iso"/>
> <target dev="hdb" bus="ide"/>
> <readonly/>
> </disk>
>
> These devices don't have disk->format parameter, so we should
> allow to add disks with format = VIR_STORAGE_FILE_NONE.
>
> If user select boot from HDD and add new Cdrom device then we see
>
> <disk type="file" device="cdrom">
> <target dev="hdb" bus="ide"/>
> <readonly/>
> </disk>
>
> Cdrom device doesn't have disk->source parameter,
> it means that user did select "attach to real device" or "use ISO".
> So we should not return error if we get device with empty source path.
> ---
> diff from v1:
> Add commit description
> Move this commit to patch series
>
> src/vz/vz_sdk.c | 22 +++++++++++++---------
> 1 file changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
> index c5f8edd..1fcfb2e 100644
> --- a/src/vz/vz_sdk.c
> +++ b/src/vz/vz_sdk.c
> @@ -2026,8 +2026,9 @@ prlsdkCheckUnsupportedParams(PRL_HANDLE sdkdom,
> virDomainDefPtr def)
> }
>
> if (!IS_CT(def)) {
> - if (def->os.nBootDevs != 1 ||
> - def->os.bootDevs[0] != VIR_DOMAIN_BOOT_DISK ||
> + if (def->os.nBootDevs == 0 ||
> + (def->os.bootDevs[0] != VIR_DOMAIN_BOOT_DISK &&
> + def->os.bootDevs[0] != VIR_DOMAIN_BOOT_CDROM) ||
> def->os.init != NULL || def->os.initargv != NULL) {
>
> virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> @@ -3192,11 +3193,12 @@ static int prlsdkAddDisk(PRL_HANDLE sdkdom,
>
> if (disk->src->type == VIR_STORAGE_TYPE_FILE) {
> if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK &&
> - virDomainDiskGetFormat(disk) != VIR_STORAGE_FILE_PLOOP) {
> + (virDomainDiskGetFormat(disk) != VIR_STORAGE_FILE_PLOOP &&
> + virDomainDiskGetFormat(disk) != VIR_STORAGE_FILE_NONE)) {
Virtual machines in vz7 use only qcow2, so we should accept VIR_STORAGE_FILE_PLOOP
for containers and qcow2 for VMs.
>
> virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid format of "
> - "disk %s, vz driver
> supports only "
> - "images in ploop
> format."), disk->src->path);
> + "disk %s, it should be
> either not set or "
> + "ploop format."), disk-
> >src->path);
> goto cleanup;
> }
>
> @@ -3218,11 +3220,13 @@ static int prlsdkAddDisk(PRL_HANDLE sdkdom,
> pret = PrlVmDev_SetEmulatedType(sdkdisk, emutype);
> prlsdkCheckRetGoto(pret, cleanup);
>
> - pret = PrlVmDev_SetSysName(sdkdisk, disk->src->path);
> - prlsdkCheckRetGoto(pret, cleanup);
> + if (disk->src->path != NULL) {
> + pret = PrlVmDev_SetSysName(sdkdisk, disk->src->path);
> + prlsdkCheckRetGoto(pret, cleanup);
>
> - pret = PrlVmDev_SetFriendlyName(sdkdisk, disk->src->path);
> - prlsdkCheckRetGoto(pret, cleanup);
> + pret = PrlVmDev_SetFriendlyName(sdkdisk, disk->src->path);
> + prlsdkCheckRetGoto(pret, cleanup);
> + }
>
> drive = &disk->info.addr.drive;
> if (drive->controller > 0) {
More information about the libvir-list
mailing list