From nobody Sun Feb 8 14:52:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584525093; cv=none; d=zohomail.com; s=zohoarc; b=eXZFsHLDIWjnwinesOfZxuAE/Xh8VAERsP1R3BtgDMNNLQ4mZXYuN1qbKLFYmv5gzUey/ctu0D31xkDxEi7TVxlYyogGXUbi39XT6LK9mDf3ja0Dz1usOfMM8XRY5IuRf1Spr2omBTbC0+TKm27kg2q/9lZ6D2f0Ycz3Eyc0+Sg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584525093; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nkd2eA1HHhBkH7vtYdu5wGFpsNb5FuW8khDfzacDXfM=; b=Bw3EAoMPNR+G280fADfU7Cg7MrMCaqDEqyMVbk9cZHzNNQRlH334ON+iAZMy3J499zyCkbIGMShV6h0JNvzw3Z9WnIgVLTiJuscp/DyOUHm8sdQXMZWFrhUxbp56ua8xHvzSWeSGTXtRP3IowQZ5KHflw9L0xI+phretVTQtbS8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 1584525093032649.1705324036211; Wed, 18 Mar 2020 02:51:33 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-433-rkk3cKteNWSrF-eldUKOlQ-1; Wed, 18 Mar 2020 05:51:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E04E88010EB; Wed, 18 Mar 2020 09:51:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 66D105D9E5; Wed, 18 Mar 2020 09:51:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C2CBE85EEF; Wed, 18 Mar 2020 09:51:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02I9pK7k006812 for ; Wed, 18 Mar 2020 05:51:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 031BC9495F; Wed, 18 Mar 2020 09:51:20 +0000 (UTC) Received: from lindworm.usersys.redhat.com (unknown [10.40.192.3]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6FDD99495A for ; Wed, 18 Mar 2020 09:51:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584525092; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=nkd2eA1HHhBkH7vtYdu5wGFpsNb5FuW8khDfzacDXfM=; b=gN0L/uK2dFEIUstBXnKWTJitToIDn384WRh9mJZt89Z1fmvisi+O8ocogKz61n1omUmdmo fltOluFl6dhhi0t8PWONpEoezDAWd6HtkbuDfp4JuEgpdyhQ1uyIMBQV0AM6/HMK5YMdQu 14AdottisBzuRfWYIH8EnNJGtNgvs9M= X-MC-Unique: rkk3cKteNWSrF-eldUKOlQ-1 From: Pino Toscano To: libvir-list@redhat.com Subject: [PATCH v2 2/2] vmx: make 'fileName' optional for CD-ROMs Date: Wed, 18 Mar 2020 10:51:08 +0100 Message-Id: <20200318095108.1444801-3-ptoscano@redhat.com> In-Reply-To: <20200318095108.1444801-1-ptoscano@redhat.com> References: <20200318095108.1444801-1-ptoscano@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" It seems like CD-ROMs may have no 'fileName' property specified in case there is nothing configured as attachment for the drive. Hence, make sure that virVMXParseDisk() do not consider it mandatory anymore, considering it an empty block cdrom device. Sadly virVMXParseDisk() is used also to parse disk and floppies, so make sure that a NULL fileName is handled in cdrom- and floppy-related paths. https://bugzilla.redhat.com/show_bug.cgi?id=3D1808610 Signed-off-by: Pino Toscano --- src/vmx/vmx.c | 25 ++++++++++--------- .../vmx2xmldata/vmx2xml-cdrom-ide-empty-2.vmx | 4 +++ .../vmx2xmldata/vmx2xml-cdrom-ide-empty-2.xml | 23 +++++++++++++++++ tests/vmx2xmltest.c | 1 + 4 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.vmx create mode 100644 tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.xml diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index bfc9bc7404..6c6ef7acf3 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -2207,7 +2207,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptio= nPtr xmlopt, virConfPtr con goto cleanup; =20 /* vmx:fileName -> def:src, def:type */ - if (virVMXGetConfigString(conf, fileName_name, &fileName, false) < 0) + if (virVMXGetConfigString(conf, fileName_name, &fileName, true) < 0) goto cleanup; =20 /* vmx:writeThrough -> def:cachemode */ @@ -2218,7 +2218,8 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptio= nPtr xmlopt, virConfPtr con =20 /* Setup virDomainDiskDef */ if (device =3D=3D VIR_DOMAIN_DISK_DEVICE_DISK) { - if (virStringHasCaseSuffix(fileName, ".iso") || + if (fileName =3D=3D NULL || + virStringHasCaseSuffix(fileName, ".iso") || STREQ(fileName, "emptyBackingString") || (deviceType && (STRCASEEQ(deviceType, "atapi-cdrom") || @@ -2277,7 +2278,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptio= nPtr xmlopt, virConfPtr con goto cleanup; } } else if (device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM) { - if (virStringHasCaseSuffix(fileName, ".vmdk")) { + if (fileName && virStringHasCaseSuffix(fileName, ".vmdk")) { /* * This function was called in order to parse a CDROM device, = but * .vmdk files are for harddisk devices only. Just ignore it, @@ -2285,7 +2286,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptio= nPtr xmlopt, virConfPtr con * handle it. */ goto ignore; - } else if (virStringHasCaseSuffix(fileName, ".iso")) { + } else if (fileName && virStringHasCaseSuffix(fileName, ".iso")) { char *tmp; =20 if (deviceType && STRCASENEQ(deviceType, "cdrom-image")) { @@ -2306,7 +2307,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptio= nPtr xmlopt, virConfPtr con } else if (deviceType && STRCASEEQ(deviceType, "atapi-cdrom")) { virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK); =20 - if (STRCASEEQ(fileName, "auto detect")) { + if (fileName && STRCASEEQ(fileName, "auto detect")) { ignore_value(virDomainDiskSetSource(*def, NULL)); (*def)->startupPolicy =3D VIR_DOMAIN_STARTUP_POLICY_OPTION= AL; } else if (virDomainDiskSetSource(*def, fileName) < 0) { @@ -2317,7 +2318,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptio= nPtr xmlopt, virConfPtr con (*def)->device =3D VIR_DOMAIN_DISK_DEVICE_LUN; virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK); =20 - if (STRCASEEQ(fileName, "auto detect")) { + if (fileName && STRCASEEQ(fileName, "auto detect")) { ignore_value(virDomainDiskSetSource(*def, NULL)); (*def)->startupPolicy =3D VIR_DOMAIN_STARTUP_POLICY_OPTION= AL; } else if (virDomainDiskSetSource(*def, fileName) < 0) { @@ -2325,7 +2326,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptio= nPtr xmlopt, virConfPtr con } } else if (busType =3D=3D VIR_DOMAIN_DISK_BUS_SCSI && deviceType && STRCASEEQ(deviceType, "scsi-passthru")) { - if (STRPREFIX(fileName, "/vmfs/devices/cdrom/")) { + if (fileName && STRPREFIX(fileName, "/vmfs/devices/cdrom/")) { /* SCSI-passthru CD-ROMs actually are device=3D'lun' */ (*def)->device =3D VIR_DOMAIN_DISK_DEVICE_LUN; virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK); @@ -2341,7 +2342,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptio= nPtr xmlopt, virConfPtr con */ goto ignore; } - } else if (STREQ(fileName, "emptyBackingString")) { + } else if (fileName && STREQ(fileName, "emptyBackingString")) { if (deviceType && STRCASENEQ(deviceType, "cdrom-image")) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Expecting VMX entry '%s' to be 'cdrom-im= age' " @@ -2355,7 +2356,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptio= nPtr xmlopt, virConfPtr con virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid or not yet handled value '%s' " "for VMX entry '%s' for device type '%s'"), - fileName, fileName_name, + NULLSTR(fileName), fileName_name, deviceType ? deviceType : "unknown"); goto cleanup; } @@ -2365,10 +2366,10 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOpt= ionPtr xmlopt, virConfPtr con if (virDomainDiskSetSource(*def, fileName) < 0) goto cleanup; } else if (fileType !=3D NULL && STRCASEEQ(fileType, "file")) { - char *tmp; + char *tmp =3D NULL; =20 virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE); - if (!(tmp =3D ctx->parseFileName(fileName, ctx->opaque))) + if (fileName && !(tmp =3D ctx->parseFileName(fileName, ctx->op= aque))) goto cleanup; if (virDomainDiskSetSource(*def, tmp) < 0) { VIR_FREE(tmp); @@ -2379,7 +2380,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptio= nPtr xmlopt, virConfPtr con virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid or not yet handled value '%s' " "for VMX entry '%s' for device type '%s'"), - fileName, fileName_name, + NULLSTR(fileName), fileName_name, deviceType ? deviceType : "unknown"); goto cleanup; } diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.vmx b/tests/vmx2xm= ldata/vmx2xml-cdrom-ide-empty-2.vmx new file mode 100644 index 0000000000..36286cb20f --- /dev/null +++ b/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.vmx @@ -0,0 +1,4 @@ +config.version =3D "8" +virtualHW.version =3D "4" +ide0:0.present =3D "true" +ide0:0.deviceType =3D "atapi-cdrom" diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.xml b/tests/vmx2xm= ldata/vmx2xml-cdrom-ide-empty-2.xml new file mode 100644 index 0000000000..af4a5ff9f6 --- /dev/null +++ b/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.xml @@ -0,0 +1,23 @@ + + 00000000-0000-0000-0000-000000000000 + 32768 + 32768 + 1 + + hvm + + + destroy + restart + destroy + + + +
+ + + + + diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index 8d7b8ba2a4..1966aed6fe 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -218,6 +218,7 @@ mymain(void) DO_TEST("cdrom-scsi-passthru", "cdrom-scsi-passthru"); DO_TEST("cdrom-ide-file", "cdrom-ide-file"); DO_TEST("cdrom-ide-empty", "cdrom-ide-empty"); + DO_TEST("cdrom-ide-empty-2", "cdrom-ide-empty-2"); DO_TEST("cdrom-ide-device", "cdrom-ide-device"); DO_TEST("cdrom-ide-raw-device", "cdrom-ide-raw-device"); DO_TEST("cdrom-ide-raw-auto-detect", "cdrom-ide-raw-auto-detect"); --=20 2.25.1