From nobody Sun Feb 8 14:10:46 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; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1567552008; cv=none; d=zoho.com; s=zohoarc; b=ENd6fbQXIMefhEEQyU0yXeDiVCZ2vm0EfgrPFjOSJe3fBFnvqi/PPXkJZSNww6GujLVaT8yP+tpvtFX8nt0ua6ANDN9oQMqzjOWha98b4lp6XXXcdtuEZV63AukVs8qVGToFF6KfTkCqNhp5oRa77N+0j30jTdlY154oBi6mc4s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567552008; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=I/qkkWj6Cw8mFa+wj2c4xK7YaX0Eaic+psg8jajHU74=; b=PY7jvaxCs0zOHvrqA3kcbvbYk0yhWeA/aR065MaGi259/4bBnRUnRw/0S62Ps0+QOOCJuZe4+MU7qP0z849scF6V1AHd5iGbNVothiWCuksdxi9age1O51Zu0cFaf/4gUGTI8ay0HLW/eZgTFYqY4kGZ2STn6fPP+q548H0Nq9w= ARC-Authentication-Results: i=1; mx.zoho.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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1567552008421952.7174191824848; Tue, 3 Sep 2019 16:06:48 -0700 (PDT) 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 0C46D3090FD9; Tue, 3 Sep 2019 23:06:47 +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 8EE385E1D1; Tue, 3 Sep 2019 23:06:46 +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 417C22551F; Tue, 3 Sep 2019 23:06:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83N6OwN030524 for ; Tue, 3 Sep 2019 19:06:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9EE2419D70; Tue, 3 Sep 2019 23:06:24 +0000 (UTC) Received: from mx1.redhat.com (ext-mx21.extmail.prod.ext.phx2.redhat.com [10.5.110.62]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A3BC194B2 for ; Tue, 3 Sep 2019 23:06:19 +0000 (UTC) Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) (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 E599F18C4264 for ; Tue, 3 Sep 2019 23:06:18 +0000 (UTC) Received: by mail-qk1-f195.google.com with SMTP id f10so17824363qkg.7 for ; Tue, 03 Sep 2019 16:06:18 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:5c9f:9471:e230:52b:8c93]) by smtp.gmail.com with ESMTPSA id r19sm8383133qtm.44.2019.09.03.16.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 16:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DNUTJi6U489kYXpk3gtmLiv1YX9GG/64VelrrCNxEh0=; b=G4SDaBpCfNXxpCzm0/QKuUUEb7ZiENUm013Z0HebvIPlPSdBPD5LCVbbUexRQTcrCr 4eMkBpR244IyfGcRiyxDc+3vpN8pz1zarXLHfL1mU1OEg/veYDdnvy3lxZsHl8Iqq45v uEO2rx2x/TsBz7bHUfhmC9ZSRkqQg9Qdr9vuNoFF2pc9KoakTion1lN7/8Pn8xwS42wr a3JDwnK4aB/F6E8gDydmC4pyQUEZT7JMvkl6QiD/0qJf4k5/87WWqPs2A3VYk5e2h+PF 277nD0ywjkTz8qJ/jltNBSlkGPVUo2EJqpLTktzaCb0JR98KgpMSrmfpNH2FlpiBdt/G IhkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DNUTJi6U489kYXpk3gtmLiv1YX9GG/64VelrrCNxEh0=; b=CnoOxt22M4bL1vJSACUuhd9WSX7mf4VBlXZH182Vf+PQlYBkBVdgp3dz6pwVg7821k e/f29cDG5bojqK9AYVWrL2GUwleYBQKQ7vmybZ+KQofsrMmEqnYFdgfL7r6Efw0fXeF1 CUkSiceGi7jw1UTXZkyEoCCP0uf72zOyqBpG3NIrPKdx5UP8YsjVOjZAZny77ej6QUqc IFyGfO3CxEmP0Eayd/9O64tlK14ugmSa+4s+aXEPzQBNUJWNxJF2zjt93jbtNvVuzQve Ej3A4aUy9w08jENitXKImWVSD5VMP8YTCJHzveDNrMe0+8XEE0hANAeRxisauz7dQKJa gWQw== X-Gm-Message-State: APjAAAULBa/nZ7huOowu69gnpBxwKg7Gtp3Giaz3tRUgzoCDh/G9gt5g ObKepaicdCWmvEv9H8Wxtl5Wa5DF X-Google-Smtp-Source: APXvYqwyZfhYicUqd5Rqgosa595ccbofhTBjdGcfyKXxG6/VELR0K2CtIf+rQYEoqvHYi+kHdppEmg== X-Received: by 2002:a37:ad8:: with SMTP id 207mr18062156qkk.38.1567551978147; Tue, 03 Sep 2019 16:06:18 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 20:06:07 -0300 Message-Id: <20190903230607.21557-4-danielhb413@gmail.com> In-Reply-To: <20190903230607.21557-1-danielhb413@gmail.com> References: <20190903230607.21557-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Tue, 03 Sep 2019 23:06:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Tue, 03 Sep 2019 23:06:19 +0000 (UTC) for IP:'209.85.222.195' DOMAIN:'mail-qk1-f195.google.com' HELO:'mail-qk1-f195.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.15 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.222.195 mail-qk1-f195.google.com 209.85.222.195 mail-qk1-f195.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.62 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza Subject: [libvirt] [PATCH v1 3/3] qemu_conf.c: introduce qemuAddRemoveSharedDeviceInternal 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-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.43]); Tue, 03 Sep 2019 23:06:47 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" After the previous commits, qemuAddSharedDevice() and qemuRemoveSharedDevice() are now the same code with a different flag to call the internal functions. This patch aggregates the common code into a new function called qemuAddRemoveSharedDeviceInternal() to further reduce code repetition. Both qemuAddSharedDevice() and qemuRemoveSharedDevice() are kept since they are public functions used elsewhere. No functional change was made. Signed-off-by: Daniel Henrique Barboza --- src/qemu/qemu_conf.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 422f0d743d..6ce2d10ac7 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1793,6 +1793,26 @@ qemuAddRemoveSharedHostdevInternal(virQEMUDriverPtr = driver, =20 } =20 +static int +qemuAddRemoveSharedDeviceInternal(virQEMUDriverPtr driver, + virDomainDeviceDefPtr dev, + const char *name, + bool addDevice) +{ + /* Currently the only conflicts we have to care about for + * the shared disk and shared host device is "sgio" setting, + * which is only valid for block disk and scsi host device. + */ + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_DISK) + return qemuAddRemoveSharedDiskInternal(driver, dev->data.disk, + name, addDevice); + else if (dev->type =3D=3D VIR_DOMAIN_DEVICE_HOSTDEV) + return qemuAddRemoveSharedHostdevInternal(driver, dev->data.hostde= v, + name, addDevice); + else + return 0; +} + =20 /* qemuAddSharedDevice: * @driver: Pointer to qemu driver struct @@ -1808,18 +1828,7 @@ qemuAddSharedDevice(virQEMUDriverPtr driver, virDomainDeviceDefPtr dev, const char *name) { - /* Currently the only conflicts we have to care about for - * the shared disk and shared host device is "sgio" setting, - * which is only valid for block disk and scsi host device. - */ - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_DISK) - return qemuAddRemoveSharedDiskInternal(driver, dev->data.disk, - name, true); - else if (dev->type =3D=3D VIR_DOMAIN_DEVICE_HOSTDEV) - return qemuAddRemoveSharedHostdevInternal(driver, dev->data.hostde= v, - name, true); - else - return 0; + return qemuAddRemoveSharedDeviceInternal(driver, dev, name, true); } =20 =20 @@ -1846,14 +1855,7 @@ qemuRemoveSharedDevice(virQEMUDriverPtr driver, virDomainDeviceDefPtr dev, const char *name) { - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_DISK) - return qemuAddRemoveSharedDiskInternal(driver, dev->data.disk, - name, false); - else if (dev->type =3D=3D VIR_DOMAIN_DEVICE_HOSTDEV) - return qemuAddRemoveSharedHostdevInternal(driver, dev->data.hostde= v, - name, false); - else - return 0; + return qemuAddRemoveSharedDeviceInternal(driver, dev, name, false); } =20 =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list