From nobody Tue Feb 10 11:23:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 151008060350251.67408338967084; Tue, 7 Nov 2017 10:50:03 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id A11E461E42; Tue, 7 Nov 2017 18:50:01 +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 484E55D979; Tue, 7 Nov 2017 18:50:01 +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 011B63FCFB; Tue, 7 Nov 2017 18:50:01 +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 vA7IngU7024886 for ; Tue, 7 Nov 2017 13:49:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5A9F55EDE4; Tue, 7 Nov 2017 18:49:42 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 55B055EDE0 for ; Tue, 7 Nov 2017 18:49:42 +0000 (UTC) Received: from mail-qk0-f171.google.com (mail-qk0-f171.google.com [209.85.220.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 420298765C for ; Tue, 7 Nov 2017 18:49:41 +0000 (UTC) Received: by mail-qk0-f171.google.com with SMTP id n66so267318qki.8 for ; Tue, 07 Nov 2017 10:49:41 -0800 (PST) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id t34sm1313175qtb.79.2017.11.07.10.49.39 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Nov 2017 10:49:39 -0800 (PST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A11E461E42 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A11E461E42 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="2G6f6vr5" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 420298765C Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 420298765C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=NxQqW3hdWHbs5KNK0uLPFX/eh57ya1AHr9vWwrZOOIY=; b=2G6f6vr5TYvk84gkNaHyWfK7jj4eGx4zNSUBBVIpX9VGlWjPLQtZ/iUz6xFXWsvRZi EUyprcmUSMMo2i1r6Qyl/J6UMNTWoq/b/YcteptJf/ZSd1HObW7f7xPa18OW81JWJg8K HjJuBQ6FL9O2/i7DQeK2n4CVS4lKMw8NsaNn/Vr53fnUs7A/qdwlOa6XLiMxj+4210MU z+9e4AfEAKVustzCxdLBJ5qjA1bOFqU23uT9/Vp9MQn2032i8k1qJHC5q//rReh8gtOT PS3s3rWgzmjvUy0N8zb0gVZ5pEjl8cfobR8K9fM8Om6p1NhYwSl8lLUsgqo6FSf99JpU ITug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=NxQqW3hdWHbs5KNK0uLPFX/eh57ya1AHr9vWwrZOOIY=; b=BBgthUXZ/IFYUkSS6/i04jSbP+0uex+Gvw1QMYUhCKrLbL8Nm8JgzO3Al8tDdGoJxu L4XUUQEXASBL53U8EDkqIWAopbrF9+y9HlDYFrXMF39zcRTFqzeMgLJCseYzhIGekJys RUJ7g2BFcuQryxEpWUK+JvIMZIDXfmowDzwvx8xhKa+3OLr4OS/Vm5OV+7EMoTi2cgxK S/tzg7smi3ikOOmmGrPoOU3A45L6JzvmKU8fIGHpHKHmCWOfAEjZHbogO5J03DARzmJP ZHzP815ktFMl3SXuQ6JEiQm+fpKcmLoMtv3mIYf3J90cB15hw4JKt1HVJOY50EMkbO0j rUzA== X-Gm-Message-State: AJaThX5yvUcBUvl1ZoTJy67gVaGlFwkYgs2vrTEs0LlABq1WnXOMPwsu f1K6DO+vWNQLDHBpdQjIX3cKiD4VDXU= X-Google-Smtp-Source: ABhQp+TjtxjNw8Rarjf9//Iiz970P3J9b5/M489ggIsZFmBZ0u/hVkP3Y6SWhcWeep1fQU51U/W1LQ== X-Received: by 10.55.161.4 with SMTP id k4mr3467172qke.204.1510080580197; Tue, 07 Nov 2017 10:49:40 -0800 (PST) From: Dawid Zamirski To: libvir-list@redhat.com Date: Tue, 7 Nov 2017 13:49:27 -0500 Message-Id: <20171107184930.12769-11-dzamirski@datto.com> In-Reply-To: <20171107184930.12769-1-dzamirski@datto.com> References: <20171107184930.12769-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 07 Nov 2017 18:49:41 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 07 Nov 2017 18:49:41 +0000 (UTC) for IP:'209.85.220.171' DOMAIN:'mail-qk0-f171.google.com' HELO:'mail-qk0-f171.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: -2.811 (DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.220.171 mail-qk0-f171.google.com 209.85.220.171 mail-qk0-f171.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 10/13] vbox: Process empty removable disks in dumpxml 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 07 Nov 2017 18:50:02 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Previously any removable storage device without media attached was omitted from domain XML dump. They're still (rightfully) omitted in snapshot XMl dump but need to be accounted properly to for the device names to stay in 'sync' between domain and snapshot XML dumps. --- src/vbox/vbox_common.c | 82 ++++++++++++++++++++++++++++++----------------= ---- 1 file changed, 49 insertions(+), 33 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 248f315eb..661e09a27 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3185,7 +3185,7 @@ static int vboxDumpDisks(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { vboxArray mediumAttachments =3D VBOX_ARRAY_INITIALIZER; - int ret =3D -1, diskCount =3D 0; + int ret =3D -1; IMediumAttachment *mediumAttachment =3D NULL; IMedium *medium =3D NULL; IStorageController *controller =3D NULL; @@ -3208,11 +3208,15 @@ vboxDumpDisks(virDomainDefPtr def, vboxDriverPtr da= ta, IMachine *machine) if (!mediumAttachment) continue; =20 - gVBoxAPI.UIMediumAttachment.GetMedium(mediumAttachment, &medium); - if (medium) { - def->ndisks++; - VBOX_RELEASE(medium); + rc =3D gVBoxAPI.UIMediumAttachment.GetMedium(mediumAttachment, &me= dium); + if (NS_FAILED(rc)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get IMedium, rc=3D%08x"), rc); + goto cleanup; } + + def->ndisks++; + VBOX_RELEASE(medium); } =20 /* Allocate mem, if fails return error */ @@ -3228,7 +3232,7 @@ vboxDumpDisks(virDomainDefPtr def, vboxDriverPtr data= , IMachine *machine) } =20 /* get the attachment details here */ - for (i =3D 0; i < mediumAttachments.count && diskCount < def->ndisks; = i++) { + for (i =3D 0; i < mediumAttachments.count; i++) { mediumAttachment =3D mediumAttachments.items[i]; controller =3D NULL; controllerName =3D NULL; @@ -3240,7 +3244,7 @@ vboxDumpDisks(virDomainDefPtr def, vboxDriverPtr data= , IMachine *machine) mediumLocUtf8 =3D NULL; devicePort =3D 0; deviceSlot =3D 0; - disk =3D def->disks[diskCount]; + disk =3D def->disks[i]; =20 if (!mediumAttachment) continue; @@ -3252,9 +3256,6 @@ vboxDumpDisks(virDomainDefPtr def, vboxDriverPtr data= , IMachine *machine) goto cleanup; } =20 - if (!medium) - continue; - rc =3D gVBoxAPI.UIMediumAttachment.GetController(mediumAttachment, &controllerName); if (NS_FAILED(rc)) { @@ -3274,22 +3275,6 @@ vboxDumpDisks(virDomainDefPtr def, vboxDriverPtr dat= a, IMachine *machine) goto cleanup; } =20 - rc =3D gVBoxAPI.UIMedium.GetLocation(medium, &mediumLocUtf16); - if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get medium storage location, rc=3D= %08x"), - rc); - goto cleanup; - } - - VBOX_UTF16_TO_UTF8(mediumLocUtf16, &mediumLocUtf8); - - if (virDomainDiskSetSource(disk, mediumLocUtf8) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Could not set disk source")); - goto cleanup; - } - rc =3D gVBoxAPI.UIMediumAttachment.GetType(mediumAttachment, &devi= ceType); if (NS_FAILED(rc)) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -3315,11 +3300,30 @@ vboxDumpDisks(virDomainDefPtr def, vboxDriverPtr da= ta, IMachine *machine) rc); goto cleanup; } - rc =3D gVBoxAPI.UIMedium.GetReadOnly(medium, &readOnly); - if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get read only state, rc=3D%08x"), = rc); - goto cleanup; + + if (medium) { + rc =3D gVBoxAPI.UIMedium.GetLocation(medium, &mediumLocUtf16); + if (NS_FAILED(rc)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get medium storage location, r= c=3D%08x"), + rc); + goto cleanup; + } + + VBOX_UTF16_TO_UTF8(mediumLocUtf16, &mediumLocUtf8); + + if (virDomainDiskSetSource(disk, mediumLocUtf8) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not set disk source")); + goto cleanup; + } + + rc =3D gVBoxAPI.UIMedium.GetReadOnly(medium, &readOnly); + if (NS_FAILED(rc)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get read only state, rc=3D%08x= "), rc); + goto cleanup; + } } =20 disk->dst =3D vboxGenerateMediumName(storageBus, devicePort, devic= eSlot, @@ -3356,8 +3360,6 @@ vboxDumpDisks(virDomainDefPtr def, vboxDriverPtr data= , IMachine *machine) =20 virDomainDiskSetType(disk, VIR_STORAGE_TYPE_FILE); =20 - diskCount++; - VBOX_UTF16_FREE(controllerName); VBOX_UTF8_FREE(mediumLocUtf8); VBOX_UTF16_FREE(mediumLocUtf16); @@ -5788,6 +5790,13 @@ vboxSnapshotGetReadWriteDisks(virDomainSnapshotDefPt= r def, =20 /* skip empty removable disk */ if (!disk) { + /* removable disks with empty (ejected) media won't be display= ed + * in XML, but we need to update "sdCount" so that device name= s match + * in domain dumpxml and snapshot dumpxml + */ + if (storageBus =3D=3D StorageBus_SATA || storageBus =3D=3D Sto= rageBus_SCSI) + sdCount++; + VBOX_RELEASE(storageController); continue; } @@ -5996,6 +6005,13 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDefPtr= def, =20 /* skip empty removable disk */ if (!disk) { + /* removable disks with empty (ejected) media won't be display= ed + * in XML, but we need to update "sdCount" so that device name= s match + * in domain dumpxml and snapshot dumpxml + */ + if (storageBus =3D=3D StorageBus_SATA || storageBus =3D=3D Sto= rageBus_SCSI) + sdCount++; + VBOX_RELEASE(storageController); continue; } --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list