From patchwork Fri Jan 8 03:49:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 59321 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp311166lbb; Thu, 7 Jan 2016 19:53:32 -0800 (PST) X-Received: by 10.140.86.243 with SMTP id p106mr143344794qgd.1.1452225205084; Thu, 07 Jan 2016 19:53:25 -0800 (PST) Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com. [209.132.183.24]) by mx.google.com with ESMTPS id q7si76246422qhb.86.2016.01.07.19.53.24 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Jan 2016 19:53:25 -0800 (PST) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u083ox7d008837; Thu, 7 Jan 2016 22:50:59 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u083oFjm005727 for ; Thu, 7 Jan 2016 22:50:15 -0500 Received: from colepc.redhat.com (ovpn-113-33.phx2.redhat.com [10.3.113.33]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u083oBta030219; Thu, 7 Jan 2016 22:50:15 -0500 From: Cole Robinson To: libvirt-list@redhat.com Date: Thu, 7 Jan 2016 22:49:59 -0500 Message-Id: <6e205192009450e607a9602c0d5baef9844ad0fd.1452224621.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/12] qemu: domain: split out post parse default device handling 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 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com Should be a no-op --- src/qemu/qemu_domain.c | 53 +++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 20 deletions(-) -- 2.5.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index bb8d47f..26a29b1 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1025,14 +1025,10 @@ virDomainXMLNamespace virQEMUDriverDomainXMLNamespace = { .href = qemuDomainDefNamespaceHref, }; - static int -qemuDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps, - void *opaque) +qemuDomainDefAddDefaultDevices(virDomainDefPtr def, + virQEMUCapsPtr qemuCaps) { - virQEMUDriverPtr driver = opaque; - virQEMUCapsPtr qemuCaps = NULL; bool addDefaultUSB = true; bool addImplicitSATA = false; bool addPCIRoot = false; @@ -1043,20 +1039,6 @@ qemuDomainDefPostParse(virDomainDefPtr def, bool addPanicDevice = false; int ret = -1; - if (def->os.bootloader || def->os.bootloaderArgs) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("bootloader is not supported by QEMU")); - return ret; - } - - /* check for emulator and create a default one if needed */ - if (!def->emulator && - !(def->emulator = virDomainDefGetDefaultEmulator(def, caps))) - return ret; - - - qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator); - /* Add implicit PCI root controller if the machine has one */ switch (def->os.arch) { case VIR_ARCH_I686: @@ -1212,6 +1194,37 @@ qemuDomainDefPostParse(virDomainDefPtr def, ret = 0; cleanup: + return ret; +} + + +static int +qemuDomainDefPostParse(virDomainDefPtr def, + virCapsPtr caps, + void *opaque) +{ + virQEMUDriverPtr driver = opaque; + virQEMUCapsPtr qemuCaps = NULL; + int ret = -1; + + if (def->os.bootloader || def->os.bootloaderArgs) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("bootloader is not supported by QEMU")); + return ret; + } + + /* check for emulator and create a default one if needed */ + if (!def->emulator && + !(def->emulator = virDomainDefGetDefaultEmulator(def, caps))) + return ret; + + qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator); + + if (qemuDomainDefAddDefaultDevices(def, qemuCaps) < 0) + goto cleanup; + + ret = 0; + cleanup: virObjectUnref(qemuCaps); return ret; }