From nobody Sun Feb 8 18:30:20 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1490796778997106.80125268273127; Wed, 29 Mar 2017 07:12:58 -0700 (PDT) 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 121427AEA7; Wed, 29 Mar 2017 14:12:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B96F7A09E4; Wed, 29 Mar 2017 14:12:56 +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 3FBBD5EC62; Wed, 29 Mar 2017 14:12:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2TE96kw020819 for ; Wed, 29 Mar 2017 10:09:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2C2F27D9F4; Wed, 29 Mar 2017 14:09:06 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.34.129.229]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A7FED7D9F1 for ; Wed, 29 Mar 2017 14:09:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 121427AEA7 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 121427AEA7 From: Andrea Bolognani To: libvir-list@redhat.com Date: Wed, 29 Mar 2017 16:08:52 +0200 Message-Id: <1490796536-4529-2-git-send-email-abologna@redhat.com> In-Reply-To: <1490796536-4529-1-git-send-email-abologna@redhat.com> References: <1490796536-4529-1-git-send-email-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/5] qemu: Split virQEMUCapsInitArchQMPBasic() X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 29 Mar 2017 14:12:57 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Instead of having a single function that probes the architecture from the monitor and then sets a bunch of basic capabilities based on it, have a separate function for each part: virQEMUCapsInitQMPArch() only sets the architecture, and virQEMUCapsInitQMPBasicArch() only sets the capabilities. This split will be useful later on, when we will want to set basic capabilities from the test suite without having to go through the pain of mocking the monitor. --- This is 99% pure code motion; however, an early 'return -1' has been converted to the equivalent 'goto cleanup'. src/qemu/qemu_capabilities.c | 42 +++++++++++++++++++++++++++++++---------= -- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index f51141b..eec2ee4 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4177,18 +4177,25 @@ virQEMUCapsInitQMPBasic(virQEMUCapsPtr qemuCaps) virQEMUCapsSet(qemuCaps, QEMU_CAPS_DISPLAY); } =20 -/* Capabilities that are architecture depending - * initialized for QEMU. + +/** + * virQEMUCapsInitQMPArch: + * @qemuCaps: QEMU capabilities + * @mon: QEMU monitor + * + * Initialize the architecture for @qemuCaps by asking @mon. + * + * Returns: 0 on success, <0 on failure */ static int -virQEMUCapsInitArchQMPBasic(virQEMUCapsPtr qemuCaps, +virQEMUCapsInitQMPArch(virQEMUCapsPtr qemuCaps, qemuMonitorPtr mon) { char *archstr =3D NULL; int ret =3D -1; =20 if (!(archstr =3D qemuMonitorGetTargetArch(mon))) - return -1; + goto cleanup; =20 if ((qemuCaps->arch =3D virQEMUCapsArchFromString(archstr)) =3D=3D VIR= _ARCH_NONE) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -4196,18 +4203,29 @@ virQEMUCapsInitArchQMPBasic(virQEMUCapsPtr qemuCaps, goto cleanup; } =20 + ret =3D 0; + + cleanup: + VIR_FREE(archstr); + return ret; +} + + +/** + * virQEMUCapsInitQMPBasicArch: + * @qemuCaps: QEMU capabilities + * + * Initialize @qemuCaps with basic architecture-dependent capabilities. + */ +static void +virQEMUCapsInitQMPBasicArch(virQEMUCapsPtr qemuCaps) +{ /* ACPI/HPET/KVM PIT are x86 specific */ if (ARCH_IS_X86(qemuCaps->arch)) { virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_ACPI); virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_HPET); virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_KVM_PIT); } - - ret =3D 0; - - cleanup: - VIR_FREE(archstr); - return ret; } =20 =20 @@ -4432,9 +4450,11 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, =20 virQEMUCapsInitQMPBasic(qemuCaps); =20 - if (virQEMUCapsInitArchQMPBasic(qemuCaps, mon) < 0) + if (virQEMUCapsInitQMPArch(qemuCaps, mon) < 0) goto cleanup; =20 + virQEMUCapsInitQMPBasicArch(qemuCaps); + /* USB option is supported v1.3.0 onwards */ if (qemuCaps->version >=3D 1003000) virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_USB_OPT); --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list