From nobody Sun Apr 28 20:37:18 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15193960727614.569131376013843; Fri, 23 Feb 2018 06:27:52 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1E072629C5; Fri, 23 Feb 2018 14:27:51 +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 90D9760BE7; Fri, 23 Feb 2018 14:27:50 +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 BBB474A46D; Fri, 23 Feb 2018 14:27:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1NERkeK032674 for ; Fri, 23 Feb 2018 09:27:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 84E3F9C04F; Fri, 23 Feb 2018 14:27:46 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B0FA9C04C for ; Fri, 23 Feb 2018 14:27:46 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Fri, 23 Feb 2018 15:27:27 +0100 Message-Id: <8b44ab737e3f5f3c293091cea3fe052f49da916d.1519395939.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/16] vboxDumpSharedFolders: rename non-standard label 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: , Content-Type: text/plain; charset="utf-8" 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 23 Feb 2018 14:27:51 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 s/sharedFoldersCleanup/cleanup/ Signed-off-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 07f430878..e1629b07f 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3640,10 +3640,10 @@ vboxDumpSharedFolders(virDomainDefPtr def, vboxDriv= erPtr data, IMachine *machine gVBoxAPI.UArray.handleMachineGetSharedFol= ders(machine)); =20 if (sharedFolders.count <=3D 0) - goto sharedFoldersCleanup; + goto cleanup; =20 if (VIR_ALLOC_N(def->fss, sharedFolders.count) < 0) - goto sharedFoldersCleanup; + goto cleanup; =20 for (i =3D 0; i < sharedFolders.count; i++) { ISharedFolder *sharedFolder =3D sharedFolders.items[i]; @@ -3654,7 +3654,7 @@ vboxDumpSharedFolders(virDomainDefPtr def, vboxDriver= Ptr data, IMachine *machine PRBool writable =3D PR_FALSE; =20 if (VIR_ALLOC(def->fss[i]) < 0) - goto sharedFoldersCleanup; + goto cleanup; =20 def->fss[i]->type =3D VIR_DOMAIN_FS_TYPE_MOUNT; =20 @@ -3663,7 +3663,7 @@ vboxDumpSharedFolders(virDomainDefPtr def, vboxDriver= Ptr data, IMachine *machine if (VIR_STRDUP(def->fss[i]->src->path, hostPath) < 0) { VBOX_UTF8_FREE(hostPath); VBOX_UTF16_FREE(hostPathUtf16); - goto sharedFoldersCleanup; + goto cleanup; } VBOX_UTF8_FREE(hostPath); VBOX_UTF16_FREE(hostPathUtf16); @@ -3673,7 +3673,7 @@ vboxDumpSharedFolders(virDomainDefPtr def, vboxDriver= Ptr data, IMachine *machine if (VIR_STRDUP(def->fss[i]->dst, name) < 0) { VBOX_UTF8_FREE(name); VBOX_UTF16_FREE(nameUtf16); - goto sharedFoldersCleanup; + goto cleanup; } VBOX_UTF8_FREE(name); VBOX_UTF16_FREE(nameUtf16); @@ -3684,7 +3684,7 @@ vboxDumpSharedFolders(virDomainDefPtr def, vboxDriver= Ptr data, IMachine *machine ++def->nfss; } =20 - sharedFoldersCleanup: + cleanup: gVBoxAPI.UArray.vboxArrayRelease(&sharedFolders); } =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:37:18 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519396088138622.3502729724007; Fri, 23 Feb 2018 06:28:08 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F170365670; Fri, 23 Feb 2018 14:28:06 +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 BDF8D60BEC; Fri, 23 Feb 2018 14:28:06 +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 849354A474; Fri, 23 Feb 2018 14:28:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1NERlqw032680 for ; Fri, 23 Feb 2018 09:27:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id 21C959C049; Fri, 23 Feb 2018 14:27:47 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDA7E9C04C for ; Fri, 23 Feb 2018 14:27:46 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Fri, 23 Feb 2018 15:27:28 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/16] vboxDumpSharedFolders: remove pointless comment 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: , Content-Type: text/plain; charset="utf-8" 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 23 Feb 2018 14:28:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Now that the functions are separate, we no longer need comment separators. Signed-off-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index e1629b07f..afd00a91a 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3630,7 +3630,6 @@ vboxDumpDisplay(virDomainDefPtr def, vboxDriverPtr da= ta, IMachine *machine) static void vboxDumpSharedFolders(virDomainDefPtr def, vboxDriverPtr data, IMachine *m= achine) { - /* shared folders */ vboxArray sharedFolders =3D VBOX_ARRAY_INITIALIZER; size_t i =3D 0; =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:37:18 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519396090016187.88504973907925; Fri, 23 Feb 2018 06:28:10 -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 60CC8E950C; Fri, 23 Feb 2018 14:28:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 382245D9C5; Fri, 23 Feb 2018 14:28:08 +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 81A4318033F0; Fri, 23 Feb 2018 14:28:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1NERlAC032685 for ; Fri, 23 Feb 2018 09:27:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id B6B2F9C049; Fri, 23 Feb 2018 14:27:47 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A8F3AF021 for ; Fri, 23 Feb 2018 14:27:47 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Fri, 23 Feb 2018 15:27:29 +0100 Message-Id: <3db78166a88ca7aa0d1ad9c7e51c2c1c43cd95c0.1519395939.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/16] vboxDumpSharedFolders: return a value 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: , Content-Type: text/plain; charset="utf-8" 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]); Fri, 23 Feb 2018 14:28:08 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 The allocation errors in this function are already handled by jumping to a cleanup label. Change the return type from void to int and return -1 on error. Signed-off-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index afd00a91a..cc7772f25 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3627,19 +3627,23 @@ vboxDumpDisplay(virDomainDefPtr def, vboxDriverPtr = data, IMachine *machine) return ret; } =20 -static void +static int vboxDumpSharedFolders(virDomainDefPtr def, vboxDriverPtr data, IMachine *m= achine) { vboxArray sharedFolders =3D VBOX_ARRAY_INITIALIZER; size_t i =3D 0; + int ret =3D -1; =20 def->nfss =3D 0; =20 gVBoxAPI.UArray.vboxArrayGet(&sharedFolders, machine, gVBoxAPI.UArray.handleMachineGetSharedFol= ders(machine)); =20 - if (sharedFolders.count <=3D 0) + if (sharedFolders.count <=3D 0) { + if (sharedFolders.count =3D=3D 0) + ret =3D 0; goto cleanup; + } =20 if (VIR_ALLOC_N(def->fss, sharedFolders.count) < 0) goto cleanup; @@ -3683,8 +3687,11 @@ vboxDumpSharedFolders(virDomainDefPtr def, vboxDrive= rPtr data, IMachine *machine ++def->nfss; } =20 + ret =3D 0; + cleanup: gVBoxAPI.UArray.vboxArrayRelease(&sharedFolders); + return ret; } =20 static void @@ -4179,7 +4186,8 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, u= nsigned int flags) if (vboxDumpDisks(def, data, machine) < 0) goto cleanup; =20 - vboxDumpSharedFolders(def, data, machine); + if (vboxDumpSharedFolders(def, data, machine) < 0) + goto cleanup; vboxDumpNetwork(def, data, machine, networkAdapterCount); vboxDumpAudio(def, data, machine); =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:37:18 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519396091740929.193620301578; Fri, 23 Feb 2018 06:28:11 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D12F0C06A814; Fri, 23 Feb 2018 14:28:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 84D356047A; Fri, 23 Feb 2018 14:28:09 +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 4C8F918033F1; Fri, 23 Feb 2018 14:28:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1NERmF4032693 for ; Fri, 23 Feb 2018 09:27:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 54FA69C04F; Fri, 23 Feb 2018 14:27:48 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF6739C04C for ; Fri, 23 Feb 2018 14:27:47 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Fri, 23 Feb 2018 15:27:30 +0100 Message-Id: <6638c832dd2e812ebefa3f85539ff047ef47108c.1519395939.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/16] vboxDumpNetwork: add temp variable for current network 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: , Content-Type: text/plain; charset="utf-8" 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 23 Feb 2018 14:28:10 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Instead of using def->nets every time, use a temporary pointer. This will allow splitting out the per-adapter code. Signed-off-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index cc7772f25..052655ca7 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3726,6 +3726,7 @@ vboxDumpNetwork(virDomainDefPtr def, vboxDriverPtr da= ta, IMachine *machine, PRUi /* Now get the details about the network cards here */ for (i =3D 0; netAdpIncCnt < def->nnets && i < networkAdapterCount; i+= +) { INetworkAdapter *adapter =3D NULL; + virDomainNetDefPtr net =3D def->nets[netAdpIncCnt]; =20 gVBoxAPI.UIMachine.GetNetworkAdapter(machine, i, &adapter); if (adapter) { @@ -3742,18 +3743,18 @@ vboxDumpNetwork(virDomainDefPtr def, vboxDriverPtr = data, IMachine *machine, PRUi gVBoxAPI.UINetworkAdapter.GetAttachmentType(adapter, &atta= chmentType); if (attachmentType =3D=3D NetworkAttachmentType_NAT) { =20 - def->nets[netAdpIncCnt]->type =3D VIR_DOMAIN_NET_TYPE_= USER; + net->type =3D VIR_DOMAIN_NET_TYPE_USER; =20 } else if (attachmentType =3D=3D NetworkAttachmentType_Bri= dged) { PRUnichar *hostIntUtf16 =3D NULL; char *hostInt =3D NULL; =20 - def->nets[netAdpIncCnt]->type =3D VIR_DOMAIN_NET_TYPE_= BRIDGE; + net->type =3D VIR_DOMAIN_NET_TYPE_BRIDGE; =20 gVBoxAPI.UINetworkAdapter.GetBridgedInterface(adapter,= &hostIntUtf16); =20 VBOX_UTF16_TO_UTF8(hostIntUtf16, &hostInt); - ignore_value(VIR_STRDUP(def->nets[netAdpIncCnt]->data.= bridge.brname, hostInt)); + ignore_value(VIR_STRDUP(net->data.bridge.brname, hostI= nt)); =20 VBOX_UTF8_FREE(hostInt); VBOX_UTF16_FREE(hostIntUtf16); @@ -3762,12 +3763,12 @@ vboxDumpNetwork(virDomainDefPtr def, vboxDriverPtr = data, IMachine *machine, PRUi PRUnichar *intNetUtf16 =3D NULL; char *intNet =3D NULL; =20 - def->nets[netAdpIncCnt]->type =3D VIR_DOMAIN_NET_TYPE_= INTERNAL; + net->type =3D VIR_DOMAIN_NET_TYPE_INTERNAL; =20 gVBoxAPI.UINetworkAdapter.GetInternalNetwork(adapter, = &intNetUtf16); =20 VBOX_UTF16_TO_UTF8(intNetUtf16, &intNet); - ignore_value(VIR_STRDUP(def->nets[netAdpIncCnt]->data.= internal.name, intNet)); + ignore_value(VIR_STRDUP(net->data.internal.name, intNe= t)); =20 VBOX_UTF8_FREE(intNet); VBOX_UTF16_FREE(intNetUtf16); @@ -3776,12 +3777,12 @@ vboxDumpNetwork(virDomainDefPtr def, vboxDriverPtr = data, IMachine *machine, PRUi PRUnichar *hostIntUtf16 =3D NULL; char *hostInt =3D NULL; =20 - def->nets[netAdpIncCnt]->type =3D VIR_DOMAIN_NET_TYPE_= NETWORK; + net->type =3D VIR_DOMAIN_NET_TYPE_NETWORK; =20 gVBoxAPI.UINetworkAdapter.GetHostOnlyInterface(adapter= , &hostIntUtf16); =20 VBOX_UTF16_TO_UTF8(hostIntUtf16, &hostInt); - ignore_value(VIR_STRDUP(def->nets[netAdpIncCnt]->data.= network.name, hostInt)); + ignore_value(VIR_STRDUP(net->data.network.name, hostIn= t)); =20 VBOX_UTF8_FREE(hostInt); VBOX_UTF16_FREE(hostIntUtf16); @@ -3790,24 +3791,24 @@ vboxDumpNetwork(virDomainDefPtr def, vboxDriverPtr = data, IMachine *machine, PRUi /* default to user type i.e. NAT in VirtualBox if this * dump is ever used to create a machine. */ - def->nets[netAdpIncCnt]->type =3D VIR_DOMAIN_NET_TYPE_= USER; + net->type =3D VIR_DOMAIN_NET_TYPE_USER; } =20 gVBoxAPI.UINetworkAdapter.GetAdapterType(adapter, &adapter= Type); if (adapterType =3D=3D NetworkAdapterType_Am79C970A) { - ignore_value(VIR_STRDUP(def->nets[netAdpIncCnt]->model= , "Am79C970A")); + ignore_value(VIR_STRDUP(net->model, "Am79C970A")); } else if (adapterType =3D=3D NetworkAdapterType_Am79C973)= { - ignore_value(VIR_STRDUP(def->nets[netAdpIncCnt]->model= , "Am79C973")); + ignore_value(VIR_STRDUP(net->model, "Am79C973")); } else if (adapterType =3D=3D NetworkAdapterType_I82540EM)= { - ignore_value(VIR_STRDUP(def->nets[netAdpIncCnt]->model= , "82540EM")); + ignore_value(VIR_STRDUP(net->model, "82540EM")); } else if (adapterType =3D=3D NetworkAdapterType_I82545EM)= { - ignore_value(VIR_STRDUP(def->nets[netAdpIncCnt]->model= , "82545EM")); + ignore_value(VIR_STRDUP(net->model, "82545EM")); } else if (adapterType =3D=3D NetworkAdapterType_I82543GC)= { - ignore_value(VIR_STRDUP(def->nets[netAdpIncCnt]->model= , "82543GC")); + ignore_value(VIR_STRDUP(net->model, "82543GC")); } else if (gVBoxAPI.APIVersion >=3D 3000051 && adapterType =3D=3D NetworkAdapterType_Virtio) { /* Only vbox 3.1 and later support NetworkAdapterType_= Virto */ - ignore_value(VIR_STRDUP(def->nets[netAdpIncCnt]->model= , "virtio")); + ignore_value(VIR_STRDUP(net->model, "virtio")); } =20 gVBoxAPI.UINetworkAdapter.GetMACAddress(adapter, &MACAddre= ssUtf16); @@ -3819,8 +3820,7 @@ vboxDumpNetwork(virDomainDefPtr def, vboxDriverPtr da= ta, IMachine *machine, PRUi MACAddress[8], MACAddress[9], MACAddress[10], MAC= Address[11]); =20 /* XXX some real error handling here some day ... */ - ignore_value(virMacAddrParse(macaddr, - &def->nets[netAdpIncCnt]->mac= )); + ignore_value(virMacAddrParse(macaddr, &net->mac)); =20 netAdpIncCnt++; =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:37:18 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519396094075479.12359393458144; Fri, 23 Feb 2018 06:28:14 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9B6314706E; Fri, 23 Feb 2018 14:28:12 +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 6793B600D2; Fri, 23 Feb 2018 14:28:12 +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 3226C4A47F; Fri, 23 Feb 2018 14:28:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1NERnIU032706 for ; Fri, 23 Feb 2018 09:27:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id E85EA9C04F; Fri, 23 Feb 2018 14:27:48 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DF1A9C049 for ; Fri, 23 Feb 2018 14:27:48 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Fri, 23 Feb 2018 15:27:31 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/16] vboxDumpNetwork: rename to vboxDumpNetworks 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: , Content-Type: text/plain; charset="utf-8" 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 23 Feb 2018 14:28:13 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Free up 'vboxDumpNetwork' for dumping single network. Signed-off-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 052655ca7..03266557a 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3695,7 +3695,7 @@ vboxDumpSharedFolders(virDomainDefPtr def, vboxDriver= Ptr data, IMachine *machine } =20 static void -vboxDumpNetwork(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine= , PRUint32 networkAdapterCount) +vboxDumpNetworks(virDomainDefPtr def, vboxDriverPtr data, IMachine *machin= e, PRUint32 networkAdapterCount) { PRUint32 netAdpIncCnt =3D 0; size_t i =3D 0; @@ -4188,7 +4188,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, u= nsigned int flags) =20 if (vboxDumpSharedFolders(def, data, machine) < 0) goto cleanup; - vboxDumpNetwork(def, data, machine, networkAdapterCount); + vboxDumpNetworks(def, data, machine, networkAdapterCount); vboxDumpAudio(def, data, machine); =20 if (vboxDumpSerial(def, data, machine, serialPortCount) < 0) --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:37:18 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519396073344675.4013209996036; Fri, 23 Feb 2018 06:27:53 -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 C6ECA612A2; Fri, 23 Feb 2018 14:27:51 +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 6C4BE5DA2A; Fri, 23 Feb 2018 14:27:51 +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 EA9404A46F; Fri, 23 Feb 2018 14:27:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1NERnH1032714 for ; Fri, 23 Feb 2018 09:27:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id 87D419C049; Fri, 23 Feb 2018 14:27:49 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CF9E9C04C for ; Fri, 23 Feb 2018 14:27:49 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Fri, 23 Feb 2018 15:27:32 +0100 Message-Id: <6c8836479538f5de15bed1a131fb0a90ebe44df2.1519395939.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/16] vboxDumpNetwork: re-introduce this function 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: , Content-Type: text/plain; charset="utf-8" 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.30]); Fri, 23 Feb 2018 14:27:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Split out per-adapter code from vboxDumpNetworks. Signed-off-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 186 +++++++++++++++++++++++++--------------------= ---- 1 file changed, 96 insertions(+), 90 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 03266557a..295f48376 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3695,6 +3695,101 @@ vboxDumpSharedFolders(virDomainDefPtr def, vboxDriv= erPtr data, IMachine *machine } =20 static void +vboxDumpNetwork(virDomainNetDefPtr net, vboxDriverPtr data, INetworkAdapte= r *adapter) +{ + PRUint32 attachmentType =3D NetworkAttachmentType_Null; + PRUint32 adapterType =3D NetworkAdapterType_Null; + PRUnichar *MACAddressUtf16 =3D NULL; + char *MACAddress =3D NULL; + char macaddr[VIR_MAC_STRING_BUFLEN] =3D {0}; + + gVBoxAPI.UINetworkAdapter.GetAttachmentType(adapter, &attachmentType); + if (attachmentType =3D=3D NetworkAttachmentType_NAT) { + + net->type =3D VIR_DOMAIN_NET_TYPE_USER; + + } else if (attachmentType =3D=3D NetworkAttachmentType_Bridged) { + PRUnichar *hostIntUtf16 =3D NULL; + char *hostInt =3D NULL; + + net->type =3D VIR_DOMAIN_NET_TYPE_BRIDGE; + + gVBoxAPI.UINetworkAdapter.GetBridgedInterface(adapter, &hostIntUtf= 16); + + VBOX_UTF16_TO_UTF8(hostIntUtf16, &hostInt); + ignore_value(VIR_STRDUP(net->data.bridge.brname, hostInt)); + + VBOX_UTF8_FREE(hostInt); + VBOX_UTF16_FREE(hostIntUtf16); + + } else if (attachmentType =3D=3D NetworkAttachmentType_Internal) { + PRUnichar *intNetUtf16 =3D NULL; + char *intNet =3D NULL; + + net->type =3D VIR_DOMAIN_NET_TYPE_INTERNAL; + + gVBoxAPI.UINetworkAdapter.GetInternalNetwork(adapter, &intNetUtf16= ); + + VBOX_UTF16_TO_UTF8(intNetUtf16, &intNet); + ignore_value(VIR_STRDUP(net->data.internal.name, intNet)); + + VBOX_UTF8_FREE(intNet); + VBOX_UTF16_FREE(intNetUtf16); + + } else if (attachmentType =3D=3D NetworkAttachmentType_HostOnly) { + PRUnichar *hostIntUtf16 =3D NULL; + char *hostInt =3D NULL; + + net->type =3D VIR_DOMAIN_NET_TYPE_NETWORK; + + gVBoxAPI.UINetworkAdapter.GetHostOnlyInterface(adapter, &hostIntUt= f16); + + VBOX_UTF16_TO_UTF8(hostIntUtf16, &hostInt); + ignore_value(VIR_STRDUP(net->data.network.name, hostInt)); + + VBOX_UTF8_FREE(hostInt); + VBOX_UTF16_FREE(hostIntUtf16); + + } else { + /* default to user type i.e. NAT in VirtualBox if this + * dump is ever used to create a machine. + */ + net->type =3D VIR_DOMAIN_NET_TYPE_USER; + } + + gVBoxAPI.UINetworkAdapter.GetAdapterType(adapter, &adapterType); + if (adapterType =3D=3D NetworkAdapterType_Am79C970A) { + ignore_value(VIR_STRDUP(net->model, "Am79C970A")); + } else if (adapterType =3D=3D NetworkAdapterType_Am79C973) { + ignore_value(VIR_STRDUP(net->model, "Am79C973")); + } else if (adapterType =3D=3D NetworkAdapterType_I82540EM) { + ignore_value(VIR_STRDUP(net->model, "82540EM")); + } else if (adapterType =3D=3D NetworkAdapterType_I82545EM) { + ignore_value(VIR_STRDUP(net->model, "82545EM")); + } else if (adapterType =3D=3D NetworkAdapterType_I82543GC) { + ignore_value(VIR_STRDUP(net->model, "82543GC")); + } else if (gVBoxAPI.APIVersion >=3D 3000051 && + adapterType =3D=3D NetworkAdapterType_Virtio) { + /* Only vbox 3.1 and later support NetworkAdapterType_Virto */ + ignore_value(VIR_STRDUP(net->model, "virtio")); + } + + gVBoxAPI.UINetworkAdapter.GetMACAddress(adapter, &MACAddressUtf16); + VBOX_UTF16_TO_UTF8(MACAddressUtf16, &MACAddress); + snprintf(macaddr, VIR_MAC_STRING_BUFLEN, + "%c%c:%c%c:%c%c:%c%c:%c%c:%c%c", + MACAddress[0], MACAddress[1], MACAddress[2], MACAddress[3], + MACAddress[4], MACAddress[5], MACAddress[6], MACAddress[7], + MACAddress[8], MACAddress[9], MACAddress[10], MACAddress[11]); + + /* XXX some real error handling here some day ... */ + ignore_value(virMacAddrParse(macaddr, &net->mac)); + + VBOX_UTF16_FREE(MACAddressUtf16); + VBOX_UTF8_FREE(MACAddress); +} + +static void vboxDumpNetworks(virDomainDefPtr def, vboxDriverPtr data, IMachine *machin= e, PRUint32 networkAdapterCount) { PRUint32 netAdpIncCnt =3D 0; @@ -3734,98 +3829,9 @@ vboxDumpNetworks(virDomainDefPtr def, vboxDriverPtr = data, IMachine *machine, PRU =20 gVBoxAPI.UINetworkAdapter.GetEnabled(adapter, &enabled); if (enabled) { - PRUint32 attachmentType =3D NetworkAttachmentType_Null; - PRUint32 adapterType =3D NetworkAdapterType_Null; - PRUnichar *MACAddressUtf16 =3D NULL; - char *MACAddress =3D NULL; - char macaddr[VIR_MAC_STRING_BUFLEN] =3D {0}; - - gVBoxAPI.UINetworkAdapter.GetAttachmentType(adapter, &atta= chmentType); - if (attachmentType =3D=3D NetworkAttachmentType_NAT) { - - net->type =3D VIR_DOMAIN_NET_TYPE_USER; - - } else if (attachmentType =3D=3D NetworkAttachmentType_Bri= dged) { - PRUnichar *hostIntUtf16 =3D NULL; - char *hostInt =3D NULL; - - net->type =3D VIR_DOMAIN_NET_TYPE_BRIDGE; - - gVBoxAPI.UINetworkAdapter.GetBridgedInterface(adapter,= &hostIntUtf16); - - VBOX_UTF16_TO_UTF8(hostIntUtf16, &hostInt); - ignore_value(VIR_STRDUP(net->data.bridge.brname, hostI= nt)); - - VBOX_UTF8_FREE(hostInt); - VBOX_UTF16_FREE(hostIntUtf16); - - } else if (attachmentType =3D=3D NetworkAttachmentType_Int= ernal) { - PRUnichar *intNetUtf16 =3D NULL; - char *intNet =3D NULL; - - net->type =3D VIR_DOMAIN_NET_TYPE_INTERNAL; - - gVBoxAPI.UINetworkAdapter.GetInternalNetwork(adapter, = &intNetUtf16); - - VBOX_UTF16_TO_UTF8(intNetUtf16, &intNet); - ignore_value(VIR_STRDUP(net->data.internal.name, intNe= t)); - - VBOX_UTF8_FREE(intNet); - VBOX_UTF16_FREE(intNetUtf16); - - } else if (attachmentType =3D=3D NetworkAttachmentType_Hos= tOnly) { - PRUnichar *hostIntUtf16 =3D NULL; - char *hostInt =3D NULL; - - net->type =3D VIR_DOMAIN_NET_TYPE_NETWORK; - - gVBoxAPI.UINetworkAdapter.GetHostOnlyInterface(adapter= , &hostIntUtf16); - - VBOX_UTF16_TO_UTF8(hostIntUtf16, &hostInt); - ignore_value(VIR_STRDUP(net->data.network.name, hostIn= t)); - - VBOX_UTF8_FREE(hostInt); - VBOX_UTF16_FREE(hostIntUtf16); - - } else { - /* default to user type i.e. NAT in VirtualBox if this - * dump is ever used to create a machine. - */ - net->type =3D VIR_DOMAIN_NET_TYPE_USER; - } - - gVBoxAPI.UINetworkAdapter.GetAdapterType(adapter, &adapter= Type); - if (adapterType =3D=3D NetworkAdapterType_Am79C970A) { - ignore_value(VIR_STRDUP(net->model, "Am79C970A")); - } else if (adapterType =3D=3D NetworkAdapterType_Am79C973)= { - ignore_value(VIR_STRDUP(net->model, "Am79C973")); - } else if (adapterType =3D=3D NetworkAdapterType_I82540EM)= { - ignore_value(VIR_STRDUP(net->model, "82540EM")); - } else if (adapterType =3D=3D NetworkAdapterType_I82545EM)= { - ignore_value(VIR_STRDUP(net->model, "82545EM")); - } else if (adapterType =3D=3D NetworkAdapterType_I82543GC)= { - ignore_value(VIR_STRDUP(net->model, "82543GC")); - } else if (gVBoxAPI.APIVersion >=3D 3000051 && - adapterType =3D=3D NetworkAdapterType_Virtio) { - /* Only vbox 3.1 and later support NetworkAdapterType_= Virto */ - ignore_value(VIR_STRDUP(net->model, "virtio")); - } - - gVBoxAPI.UINetworkAdapter.GetMACAddress(adapter, &MACAddre= ssUtf16); - VBOX_UTF16_TO_UTF8(MACAddressUtf16, &MACAddress); - snprintf(macaddr, VIR_MAC_STRING_BUFLEN, - "%c%c:%c%c:%c%c:%c%c:%c%c:%c%c", - MACAddress[0], MACAddress[1], MACAddress[2], MACA= ddress[3], - MACAddress[4], MACAddress[5], MACAddress[6], MACA= ddress[7], - MACAddress[8], MACAddress[9], MACAddress[10], MAC= Address[11]); - - /* XXX some real error handling here some day ... */ - ignore_value(virMacAddrParse(macaddr, &net->mac)); + vboxDumpNetwork(net, data, adapter); =20 netAdpIncCnt++; - - VBOX_UTF16_FREE(MACAddressUtf16); - VBOX_UTF8_FREE(MACAddress); } =20 VBOX_RELEASE(adapter); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:37:18 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519396088459730.4810855060279; Fri, 23 Feb 2018 06:28:08 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 14833C0AD1F0; Fri, 23 Feb 2018 14:28:07 +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 C1B3B6018D; Fri, 23 Feb 2018 14:28:06 +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 87A934A475; Fri, 23 Feb 2018 14:28:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1NERod7032720 for ; Fri, 23 Feb 2018 09:27:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id 25B7C9C04C; Fri, 23 Feb 2018 14:27:50 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0E17AF021 for ; Fri, 23 Feb 2018 14:27:49 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Fri, 23 Feb 2018 15:27:33 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/16] vboxDumpNetworks: reduce indentation level 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: , Content-Type: text/plain; charset="utf-8" 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 23 Feb 2018 14:28:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 The 'enabled' bool is initialized to false, there is no need to nest the conditions. Signed-off-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 295f48376..1d38001f9 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3822,20 +3822,19 @@ vboxDumpNetworks(virDomainDefPtr def, vboxDriverPtr= data, IMachine *machine, PRU for (i =3D 0; netAdpIncCnt < def->nnets && i < networkAdapterCount; i+= +) { INetworkAdapter *adapter =3D NULL; virDomainNetDefPtr net =3D def->nets[netAdpIncCnt]; + PRBool enabled =3D PR_FALSE; =20 gVBoxAPI.UIMachine.GetNetworkAdapter(machine, i, &adapter); - if (adapter) { - PRBool enabled =3D PR_FALSE; - + if (adapter) gVBoxAPI.UINetworkAdapter.GetEnabled(adapter, &enabled); - if (enabled) { - vboxDumpNetwork(net, data, adapter); =20 - netAdpIncCnt++; - } + if (enabled) { + vboxDumpNetwork(net, data, adapter); =20 - VBOX_RELEASE(adapter); + netAdpIncCnt++; } + + VBOX_RELEASE(adapter); } } =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:37:18 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 151939609125351.556454040792005; Fri, 23 Feb 2018 06:28:11 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DA026C074545; Fri, 23 Feb 2018 14:28:09 +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 AE2AF60C9C; Fri, 23 Feb 2018 14:28:09 +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 45DF74A47B; Fri, 23 Feb 2018 14:28:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1NERoUV032733 for ; Fri, 23 Feb 2018 09:27:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id BA3B09C049; Fri, 23 Feb 2018 14:27:50 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5ED459C04F for ; Fri, 23 Feb 2018 14:27:50 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Fri, 23 Feb 2018 15:27:34 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/16] vboxDumpNetwork: allocate the network too 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: , Content-Type: text/plain; charset="utf-8" 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 23 Feb 2018 14:28:10 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Move the allocation from vboxDumpNetworks inside vboxDumpNetwork. Signed-off-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 1d38001f9..2eb7af4ba 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3694,14 +3694,18 @@ vboxDumpSharedFolders(virDomainDefPtr def, vboxDriv= erPtr data, IMachine *machine return ret; } =20 -static void -vboxDumpNetwork(virDomainNetDefPtr net, vboxDriverPtr data, INetworkAdapte= r *adapter) +static virDomainNetDefPtr +vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *adapter) { PRUint32 attachmentType =3D NetworkAttachmentType_Null; PRUint32 adapterType =3D NetworkAdapterType_Null; PRUnichar *MACAddressUtf16 =3D NULL; char *MACAddress =3D NULL; char macaddr[VIR_MAC_STRING_BUFLEN] =3D {0}; + virDomainNetDefPtr net =3D NULL; + + if (VIR_ALLOC(net) < 0) + return NULL; =20 gVBoxAPI.UINetworkAdapter.GetAttachmentType(adapter, &attachmentType); if (attachmentType =3D=3D NetworkAttachmentType_NAT) { @@ -3787,6 +3791,7 @@ vboxDumpNetwork(virDomainNetDefPtr net, vboxDriverPtr= data, INetworkAdapter *ada =20 VBOX_UTF16_FREE(MACAddressUtf16); VBOX_UTF8_FREE(MACAddress); + return net; } =20 static void @@ -3813,15 +3818,13 @@ vboxDumpNetworks(virDomainDefPtr def, vboxDriverPtr= data, IMachine *machine, PRU } =20 /* Allocate memory for the networkcards which are enabled */ - if ((def->nnets > 0) && (VIR_ALLOC_N(def->nets, def->nnets) >=3D 0)) { - for (i =3D 0; i < def->nnets; i++) - ignore_value(VIR_ALLOC(def->nets[i])); - } + if (def->nnets > 0) + ignore_value(VIR_ALLOC_N(def->nets, def->nnets)); =20 /* Now get the details about the network cards here */ for (i =3D 0; netAdpIncCnt < def->nnets && i < networkAdapterCount; i+= +) { INetworkAdapter *adapter =3D NULL; - virDomainNetDefPtr net =3D def->nets[netAdpIncCnt]; + virDomainNetDefPtr net =3D NULL; PRBool enabled =3D PR_FALSE; =20 gVBoxAPI.UIMachine.GetNetworkAdapter(machine, i, &adapter); @@ -3829,9 +3832,8 @@ vboxDumpNetworks(virDomainDefPtr def, vboxDriverPtr d= ata, IMachine *machine, PRU gVBoxAPI.UINetworkAdapter.GetEnabled(adapter, &enabled); =20 if (enabled) { - vboxDumpNetwork(net, data, adapter); - - netAdpIncCnt++; + net =3D vboxDumpNetwork(data, adapter); + def->nets[netAdpIncCnt++] =3D net; } =20 VBOX_RELEASE(adapter); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:37:18 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15193960915112.4374187701787378; Fri, 23 Feb 2018 06:28:11 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5059C0AD42D; Fri, 23 Feb 2018 14:28:09 +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 8B03760C9B; Fri, 23 Feb 2018 14:28:09 +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 3E46F4A47A; Fri, 23 Feb 2018 14:28:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1NERpDT032745 for ; Fri, 23 Feb 2018 09:27:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5793F9C049; Fri, 23 Feb 2018 14:27:51 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id F345A9C04C for ; Fri, 23 Feb 2018 14:27:50 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Fri, 23 Feb 2018 15:27:35 +0100 Message-Id: <4907097a020a6fe2d5062d9bf3a57f8b8caaf15a.1519395939.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/16] vboxDumpNetworks: delete pointless comment 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: , Content-Type: text/plain; charset="utf-8" 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 23 Feb 2018 14:28:10 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 2eb7af4ba..c730c0cc0 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3799,7 +3799,7 @@ vboxDumpNetworks(virDomainDefPtr def, vboxDriverPtr d= ata, IMachine *machine, PRU { PRUint32 netAdpIncCnt =3D 0; size_t i =3D 0; - /* dump network cards if present */ + def->nnets =3D 0; /* Get which network cards are enabled */ for (i =3D 0; i < networkAdapterCount; i++) { --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:37:18 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519396098235699.92503562756; Fri, 23 Feb 2018 06:28:18 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E8A405FB27; Fri, 23 Feb 2018 14:28:16 +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 A6A3D60BEE; Fri, 23 Feb 2018 14:28:16 +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 67EEB4A489; Fri, 23 Feb 2018 14:28:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1NERqHi032750 for ; Fri, 23 Feb 2018 09:27:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id E9F089C049; Fri, 23 Feb 2018 14:27:51 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90A879C04F for ; Fri, 23 Feb 2018 14:27:51 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Fri, 23 Feb 2018 15:27:36 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/16] vboxDumpNetworks: do not allocate def->nets upfront 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: , Content-Type: text/plain; charset="utf-8" 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 23 Feb 2018 14:28:17 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Use VIR_APPEND_ELEMENT instead and change the return type to int to catch allocation errors. This removes the need to figure out the adapter count upfront. Signed-off-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index c730c0cc0..c807d2965 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3794,36 +3794,13 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter= *adapter) return net; } =20 -static void +static int vboxDumpNetworks(virDomainDefPtr def, vboxDriverPtr data, IMachine *machin= e, PRUint32 networkAdapterCount) { - PRUint32 netAdpIncCnt =3D 0; size_t i =3D 0; =20 - def->nnets =3D 0; - /* Get which network cards are enabled */ for (i =3D 0; i < networkAdapterCount; i++) { INetworkAdapter *adapter =3D NULL; - - gVBoxAPI.UIMachine.GetNetworkAdapter(machine, i, &adapter); - if (adapter) { - PRBool enabled =3D PR_FALSE; - - gVBoxAPI.UINetworkAdapter.GetEnabled(adapter, &enabled); - if (enabled) - def->nnets++; - - VBOX_RELEASE(adapter); - } - } - - /* Allocate memory for the networkcards which are enabled */ - if (def->nnets > 0) - ignore_value(VIR_ALLOC_N(def->nets, def->nnets)); - - /* Now get the details about the network cards here */ - for (i =3D 0; netAdpIncCnt < def->nnets && i < networkAdapterCount; i+= +) { - INetworkAdapter *adapter =3D NULL; virDomainNetDefPtr net =3D NULL; PRBool enabled =3D PR_FALSE; =20 @@ -3833,11 +3810,16 @@ vboxDumpNetworks(virDomainDefPtr def, vboxDriverPtr= data, IMachine *machine, PRU =20 if (enabled) { net =3D vboxDumpNetwork(data, adapter); - def->nets[netAdpIncCnt++] =3D net; + if (VIR_APPEND_ELEMENT(def->nets, def->nnets, net) < 0) { + VBOX_RELEASE(adapter); + return -1; + } } =20 VBOX_RELEASE(adapter); } + + return 0; } =20 static void @@ -4195,7 +4177,8 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, u= nsigned int flags) =20 if (vboxDumpSharedFolders(def, data, machine) < 0) goto cleanup; - vboxDumpNetworks(def, data, machine, networkAdapterCount); + if (vboxDumpNetworks(def, data, machine, networkAdapterCount) < 0) + goto cleanup; vboxDumpAudio(def, data, machine); =20 if (vboxDumpSerial(def, data, machine, serialPortCount) < 0) --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:37:18 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519396093907565.6094322072797; Fri, 23 Feb 2018 06:28:13 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 823CDD6492; Fri, 23 Feb 2018 14:28:12 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 526FB5EDE9; Fri, 23 Feb 2018 14:28:12 +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 097E818033F4; Fri, 23 Feb 2018 14:28:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1NERq4m032761 for ; Fri, 23 Feb 2018 09:27:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 89AD99C049; Fri, 23 Feb 2018 14:27:52 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E9CCAF021 for ; Fri, 23 Feb 2018 14:27:52 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Fri, 23 Feb 2018 15:27:37 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/16] vboxDumpNetwork: use virMacAddrParseHex 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: , Content-Type: text/plain; charset="utf-8" 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 23 Feb 2018 14:28:13 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Use the virMacAddrParse helper that does not require colon-separated values instead of using extra code to format it that way. Signed-off-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index c807d2965..3099e20c5 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3701,7 +3701,6 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *= adapter) PRUint32 adapterType =3D NetworkAdapterType_Null; PRUnichar *MACAddressUtf16 =3D NULL; char *MACAddress =3D NULL; - char macaddr[VIR_MAC_STRING_BUFLEN] =3D {0}; virDomainNetDefPtr net =3D NULL; =20 if (VIR_ALLOC(net) < 0) @@ -3780,18 +3779,19 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter= *adapter) =20 gVBoxAPI.UINetworkAdapter.GetMACAddress(adapter, &MACAddressUtf16); VBOX_UTF16_TO_UTF8(MACAddressUtf16, &MACAddress); - snprintf(macaddr, VIR_MAC_STRING_BUFLEN, - "%c%c:%c%c:%c%c:%c%c:%c%c:%c%c", - MACAddress[0], MACAddress[1], MACAddress[2], MACAddress[3], - MACAddress[4], MACAddress[5], MACAddress[6], MACAddress[7], - MACAddress[8], MACAddress[9], MACAddress[10], MACAddress[11]); + VBOX_UTF16_FREE(MACAddressUtf16); =20 - /* XXX some real error handling here some day ... */ - ignore_value(virMacAddrParse(macaddr, &net->mac)); + if (virMacAddrParseHex(MACAddress, &net->mac) < 0) { + VBOX_UTF8_FREE(MACAddress); + goto error; + } =20 - VBOX_UTF16_FREE(MACAddressUtf16); VBOX_UTF8_FREE(MACAddress); return net; + + error: + virDomainNetDefFree(net); + return NULL; } =20 static int --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:37:18 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15193960939526.0215713847154575; Fri, 23 Feb 2018 06:28:13 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 78E0AC0ADB47; Fri, 23 Feb 2018 14:28:12 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5302160486; Fri, 23 Feb 2018 14:28:12 +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 148A618033F5; Fri, 23 Feb 2018 14:28:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1NERrHV000305 for ; Fri, 23 Feb 2018 09:27:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 27D219C049; Fri, 23 Feb 2018 14:27:53 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id C26E29C04F for ; Fri, 23 Feb 2018 14:27:52 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Fri, 23 Feb 2018 15:27:38 +0100 Message-Id: <3ac44909b89028439b7560ae2b4f89b4449f651b.1519395939.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 12/16] vboxDumpNetwork: Use a single utf16 variable 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: , Content-Type: text/plain; charset="utf-8" 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 23 Feb 2018 14:28:13 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 There is a pattern of using two temporary utf16/utf8 variables for every value we get from VirtualBox and put in the domain definition right away. Reuse the same variable name to improve the chances of getting the function on one screen. Signed-off-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 3099e20c5..dc12bc662 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3699,7 +3699,7 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *= adapter) { PRUint32 attachmentType =3D NetworkAttachmentType_Null; PRUint32 adapterType =3D NetworkAdapterType_Null; - PRUnichar *MACAddressUtf16 =3D NULL; + PRUnichar *utf16 =3D NULL; char *MACAddress =3D NULL; virDomainNetDefPtr net =3D NULL; =20 @@ -3712,46 +3712,43 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter= *adapter) net->type =3D VIR_DOMAIN_NET_TYPE_USER; =20 } else if (attachmentType =3D=3D NetworkAttachmentType_Bridged) { - PRUnichar *hostIntUtf16 =3D NULL; char *hostInt =3D NULL; =20 net->type =3D VIR_DOMAIN_NET_TYPE_BRIDGE; =20 - gVBoxAPI.UINetworkAdapter.GetBridgedInterface(adapter, &hostIntUtf= 16); + gVBoxAPI.UINetworkAdapter.GetBridgedInterface(adapter, &utf16); =20 - VBOX_UTF16_TO_UTF8(hostIntUtf16, &hostInt); + VBOX_UTF16_TO_UTF8(utf16, &hostInt); ignore_value(VIR_STRDUP(net->data.bridge.brname, hostInt)); =20 VBOX_UTF8_FREE(hostInt); - VBOX_UTF16_FREE(hostIntUtf16); + VBOX_UTF16_FREE(utf16); =20 } else if (attachmentType =3D=3D NetworkAttachmentType_Internal) { - PRUnichar *intNetUtf16 =3D NULL; char *intNet =3D NULL; =20 net->type =3D VIR_DOMAIN_NET_TYPE_INTERNAL; =20 - gVBoxAPI.UINetworkAdapter.GetInternalNetwork(adapter, &intNetUtf16= ); + gVBoxAPI.UINetworkAdapter.GetInternalNetwork(adapter, &utf16); =20 - VBOX_UTF16_TO_UTF8(intNetUtf16, &intNet); + VBOX_UTF16_TO_UTF8(utf16, &intNet); ignore_value(VIR_STRDUP(net->data.internal.name, intNet)); =20 VBOX_UTF8_FREE(intNet); - VBOX_UTF16_FREE(intNetUtf16); + VBOX_UTF16_FREE(utf16); =20 } else if (attachmentType =3D=3D NetworkAttachmentType_HostOnly) { - PRUnichar *hostIntUtf16 =3D NULL; char *hostInt =3D NULL; =20 net->type =3D VIR_DOMAIN_NET_TYPE_NETWORK; =20 - gVBoxAPI.UINetworkAdapter.GetHostOnlyInterface(adapter, &hostIntUt= f16); + gVBoxAPI.UINetworkAdapter.GetHostOnlyInterface(adapter, &utf16); =20 - VBOX_UTF16_TO_UTF8(hostIntUtf16, &hostInt); + VBOX_UTF16_TO_UTF8(utf16, &hostInt); ignore_value(VIR_STRDUP(net->data.network.name, hostInt)); =20 VBOX_UTF8_FREE(hostInt); - VBOX_UTF16_FREE(hostIntUtf16); + VBOX_UTF16_FREE(utf16); =20 } else { /* default to user type i.e. NAT in VirtualBox if this @@ -3777,9 +3774,9 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *= adapter) ignore_value(VIR_STRDUP(net->model, "virtio")); } =20 - gVBoxAPI.UINetworkAdapter.GetMACAddress(adapter, &MACAddressUtf16); - VBOX_UTF16_TO_UTF8(MACAddressUtf16, &MACAddress); - VBOX_UTF16_FREE(MACAddressUtf16); + gVBoxAPI.UINetworkAdapter.GetMACAddress(adapter, &utf16); + VBOX_UTF16_TO_UTF8(utf16, &MACAddress); + VBOX_UTF16_FREE(utf16); =20 if (virMacAddrParseHex(MACAddress, &net->mac) < 0) { VBOX_UTF8_FREE(MACAddress); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:37:19 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519396101087699.0184397712878; Fri, 23 Feb 2018 06:28:21 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA974C0AE671; Fri, 23 Feb 2018 14:28:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6DF1360CA1; Fri, 23 Feb 2018 14:28:19 +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 2FB4118033FC; Fri, 23 Feb 2018 14:28:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1NERrnd000316 for ; Fri, 23 Feb 2018 09:27:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id B96689C04F; Fri, 23 Feb 2018 14:27:53 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 609399C04C for ; Fri, 23 Feb 2018 14:27:53 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Fri, 23 Feb 2018 15:27:39 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 13/16] vboxDumpNetwork: Use a single utf8 temp variable 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: , Content-Type: text/plain; charset="utf-8" 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 23 Feb 2018 14:28:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index dc12bc662..2943c534d 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3700,7 +3700,7 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *= adapter) PRUint32 attachmentType =3D NetworkAttachmentType_Null; PRUint32 adapterType =3D NetworkAdapterType_Null; PRUnichar *utf16 =3D NULL; - char *MACAddress =3D NULL; + char *utf8 =3D NULL; virDomainNetDefPtr net =3D NULL; =20 if (VIR_ALLOC(net) < 0) @@ -3712,42 +3712,36 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter= *adapter) net->type =3D VIR_DOMAIN_NET_TYPE_USER; =20 } else if (attachmentType =3D=3D NetworkAttachmentType_Bridged) { - char *hostInt =3D NULL; - net->type =3D VIR_DOMAIN_NET_TYPE_BRIDGE; =20 gVBoxAPI.UINetworkAdapter.GetBridgedInterface(adapter, &utf16); =20 - VBOX_UTF16_TO_UTF8(utf16, &hostInt); - ignore_value(VIR_STRDUP(net->data.bridge.brname, hostInt)); + VBOX_UTF16_TO_UTF8(utf16, &utf8); + ignore_value(VIR_STRDUP(net->data.bridge.brname, utf8)); =20 - VBOX_UTF8_FREE(hostInt); + VBOX_UTF8_FREE(utf8); VBOX_UTF16_FREE(utf16); =20 } else if (attachmentType =3D=3D NetworkAttachmentType_Internal) { - char *intNet =3D NULL; - net->type =3D VIR_DOMAIN_NET_TYPE_INTERNAL; =20 gVBoxAPI.UINetworkAdapter.GetInternalNetwork(adapter, &utf16); =20 - VBOX_UTF16_TO_UTF8(utf16, &intNet); - ignore_value(VIR_STRDUP(net->data.internal.name, intNet)); + VBOX_UTF16_TO_UTF8(utf16, &utf8); + ignore_value(VIR_STRDUP(net->data.internal.name, utf8)); =20 - VBOX_UTF8_FREE(intNet); + VBOX_UTF8_FREE(utf8); VBOX_UTF16_FREE(utf16); =20 } else if (attachmentType =3D=3D NetworkAttachmentType_HostOnly) { - char *hostInt =3D NULL; - net->type =3D VIR_DOMAIN_NET_TYPE_NETWORK; =20 gVBoxAPI.UINetworkAdapter.GetHostOnlyInterface(adapter, &utf16); =20 - VBOX_UTF16_TO_UTF8(utf16, &hostInt); - ignore_value(VIR_STRDUP(net->data.network.name, hostInt)); + VBOX_UTF16_TO_UTF8(utf16, &utf8); + ignore_value(VIR_STRDUP(net->data.network.name, utf8)); =20 - VBOX_UTF8_FREE(hostInt); + VBOX_UTF8_FREE(utf8); VBOX_UTF16_FREE(utf16); =20 } else { @@ -3775,15 +3769,15 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter= *adapter) } =20 gVBoxAPI.UINetworkAdapter.GetMACAddress(adapter, &utf16); - VBOX_UTF16_TO_UTF8(utf16, &MACAddress); + VBOX_UTF16_TO_UTF8(utf16, &utf8); VBOX_UTF16_FREE(utf16); =20 - if (virMacAddrParseHex(MACAddress, &net->mac) < 0) { - VBOX_UTF8_FREE(MACAddress); + if (virMacAddrParseHex(utf8, &net->mac) < 0) { + VBOX_UTF8_FREE(utf8); goto error; } =20 - VBOX_UTF8_FREE(MACAddress); + VBOX_UTF8_FREE(utf8); return net; =20 error: --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:37:19 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519396096876274.46742399745176; Fri, 23 Feb 2018 06:28:16 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 59FB5F571D; Fri, 23 Feb 2018 14:28:15 +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 28BC7508F4; Fri, 23 Feb 2018 14:28:15 +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 E55A94A482; Fri, 23 Feb 2018 14:28:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1NERs5H000323 for ; Fri, 23 Feb 2018 09:27:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5742E9C04F; Fri, 23 Feb 2018 14:27:54 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id F26A09C04C for ; Fri, 23 Feb 2018 14:27:53 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Fri, 23 Feb 2018 15:27:40 +0100 Message-Id: <36b86e0f03e89b2d8fc3e39577a0c81015951891.1519395939.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 14/16] vboxDumpNetwork: use a switch for attachmentType 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: , Content-Type: text/plain; charset="utf-8" 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 23 Feb 2018 14:28:16 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 2943c534d..8f5f04efb 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3707,11 +3707,13 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter= *adapter) return NULL; =20 gVBoxAPI.UINetworkAdapter.GetAttachmentType(adapter, &attachmentType); - if (attachmentType =3D=3D NetworkAttachmentType_NAT) { =20 + switch (attachmentType) { + case NetworkAttachmentType_NAT: net->type =3D VIR_DOMAIN_NET_TYPE_USER; + break; =20 - } else if (attachmentType =3D=3D NetworkAttachmentType_Bridged) { + case NetworkAttachmentType_Bridged: net->type =3D VIR_DOMAIN_NET_TYPE_BRIDGE; =20 gVBoxAPI.UINetworkAdapter.GetBridgedInterface(adapter, &utf16); @@ -3721,8 +3723,9 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *= adapter) =20 VBOX_UTF8_FREE(utf8); VBOX_UTF16_FREE(utf16); + break; =20 - } else if (attachmentType =3D=3D NetworkAttachmentType_Internal) { + case NetworkAttachmentType_Internal: net->type =3D VIR_DOMAIN_NET_TYPE_INTERNAL; =20 gVBoxAPI.UINetworkAdapter.GetInternalNetwork(adapter, &utf16); @@ -3732,8 +3735,9 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *= adapter) =20 VBOX_UTF8_FREE(utf8); VBOX_UTF16_FREE(utf16); + break; =20 - } else if (attachmentType =3D=3D NetworkAttachmentType_HostOnly) { + case NetworkAttachmentType_HostOnly: net->type =3D VIR_DOMAIN_NET_TYPE_NETWORK; =20 gVBoxAPI.UINetworkAdapter.GetHostOnlyInterface(adapter, &utf16); @@ -3743,8 +3747,9 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *= adapter) =20 VBOX_UTF8_FREE(utf8); VBOX_UTF16_FREE(utf16); + break; =20 - } else { + default: /* default to user type i.e. NAT in VirtualBox if this * dump is ever used to create a machine. */ --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:37:19 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519396104137276.1030520498035; Fri, 23 Feb 2018 06:28:24 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D9FAD53384; Fri, 23 Feb 2018 14:28: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 B2A3D6090E; Fri, 23 Feb 2018 14:28: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 716DB4A471; Fri, 23 Feb 2018 14:28:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1NERtZ8000328 for ; Fri, 23 Feb 2018 09:27:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id E927F9C049; Fri, 23 Feb 2018 14:27:54 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90480AF021 for ; Fri, 23 Feb 2018 14:27:54 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Fri, 23 Feb 2018 15:27:41 +0100 Message-Id: <6db592256fd10a6dfa3ffced12952cd3b788ef35.1519395939.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 15/16] vboxDumpNetwork: use VIR_STEAL_PTR instead of VIR_STRDUP 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: , Content-Type: text/plain; charset="utf-8" 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 23 Feb 2018 14:28:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 We can steal the strings instead of creating more copies. Signed-off-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 8f5f04efb..1a413e4ac 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3719,9 +3719,7 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *= adapter) gVBoxAPI.UINetworkAdapter.GetBridgedInterface(adapter, &utf16); =20 VBOX_UTF16_TO_UTF8(utf16, &utf8); - ignore_value(VIR_STRDUP(net->data.bridge.brname, utf8)); - - VBOX_UTF8_FREE(utf8); + VIR_STEAL_PTR(net->data.bridge.brname, utf8); VBOX_UTF16_FREE(utf16); break; =20 @@ -3731,9 +3729,7 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *= adapter) gVBoxAPI.UINetworkAdapter.GetInternalNetwork(adapter, &utf16); =20 VBOX_UTF16_TO_UTF8(utf16, &utf8); - ignore_value(VIR_STRDUP(net->data.internal.name, utf8)); - - VBOX_UTF8_FREE(utf8); + VIR_STEAL_PTR(net->data.internal.name, utf8); VBOX_UTF16_FREE(utf16); break; =20 @@ -3743,9 +3739,7 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *= adapter) gVBoxAPI.UINetworkAdapter.GetHostOnlyInterface(adapter, &utf16); =20 VBOX_UTF16_TO_UTF8(utf16, &utf8); - ignore_value(VIR_STRDUP(net->data.network.name, utf8)); - - VBOX_UTF8_FREE(utf8); + VIR_STEAL_PTR(net->data.network.name, utf8); VBOX_UTF16_FREE(utf16); break; =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:37:19 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519396098854538.4915085037114; Fri, 23 Feb 2018 06:28:18 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 057285FB45; Fri, 23 Feb 2018 14:28:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BD77860BF4; Fri, 23 Feb 2018 14:28:16 +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 82B6118033F1; Fri, 23 Feb 2018 14:28:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1NERtkK000333 for ; Fri, 23 Feb 2018 09:27:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id 873A89C04F; Fri, 23 Feb 2018 14:27:55 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DCBA9C04C for ; Fri, 23 Feb 2018 14:27:55 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Fri, 23 Feb 2018 15:27:42 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 16/16] vboxDumpNetwork: use switch for adapterType 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: , Content-Type: text/plain; charset="utf-8" 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 23 Feb 2018 14:28:17 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Also return an error when VIR_STRDUP fails. Signed-off-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 1a413e4ac..3bcca43d3 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3699,6 +3699,7 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *= adapter) { PRUint32 attachmentType =3D NetworkAttachmentType_Null; PRUint32 adapterType =3D NetworkAdapterType_Null; + const char *model =3D NULL; PRUnichar *utf16 =3D NULL; char *utf8 =3D NULL; virDomainNetDefPtr net =3D NULL; @@ -3751,21 +3752,30 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter= *adapter) } =20 gVBoxAPI.UINetworkAdapter.GetAdapterType(adapter, &adapterType); - if (adapterType =3D=3D NetworkAdapterType_Am79C970A) { - ignore_value(VIR_STRDUP(net->model, "Am79C970A")); - } else if (adapterType =3D=3D NetworkAdapterType_Am79C973) { - ignore_value(VIR_STRDUP(net->model, "Am79C973")); - } else if (adapterType =3D=3D NetworkAdapterType_I82540EM) { - ignore_value(VIR_STRDUP(net->model, "82540EM")); - } else if (adapterType =3D=3D NetworkAdapterType_I82545EM) { - ignore_value(VIR_STRDUP(net->model, "82545EM")); - } else if (adapterType =3D=3D NetworkAdapterType_I82543GC) { - ignore_value(VIR_STRDUP(net->model, "82543GC")); - } else if (gVBoxAPI.APIVersion >=3D 3000051 && - adapterType =3D=3D NetworkAdapterType_Virtio) { + switch (adapterType) { + case NetworkAdapterType_Am79C970A: + model =3D "Am79C970A"; + break; + case NetworkAdapterType_Am79C973: + model =3D "Am79C973"; + break; + case NetworkAdapterType_I82540EM: + model =3D "82540EM"; + break; + case NetworkAdapterType_I82545EM: + model =3D "82545EM"; + break; + case NetworkAdapterType_I82543GC: + model =3D "82543GC"; + break; + case NetworkAdapterType_Virtio: /* Only vbox 3.1 and later support NetworkAdapterType_Virto */ - ignore_value(VIR_STRDUP(net->model, "virtio")); + if (gVBoxAPI.APIVersion >=3D 3000051) + model =3D "virtio"; + break; } + if (VIR_STRDUP(net->model, model) < 0) + goto error; =20 gVBoxAPI.UINetworkAdapter.GetMACAddress(adapter, &utf16); VBOX_UTF16_TO_UTF8(utf16, &utf8); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list