From patchwork Wed Apr 20 21:01:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 66255 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp2675576qge; Wed, 20 Apr 2016 14:04:28 -0700 (PDT) X-Received: by 10.28.150.193 with SMTP id y184mr12552282wmd.41.1461186268602; Wed, 20 Apr 2016 14:04:28 -0700 (PDT) Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com. [209.132.183.24]) by mx.google.com with ESMTPS id d13si7991697wjz.87.2016.04.20.14.04.28 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 20 Apr 2016 14:04:28 -0700 (PDT) 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 u3KL1SHq028200; Wed, 20 Apr 2016 17:01:32 -0400 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 u3KL1Rrg024530 for ; Wed, 20 Apr 2016 17:01:27 -0400 Received: from colepc.redhat.com (ovpn-113-99.phx2.redhat.com [10.3.113.99]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3KL1QVp001960; Wed, 20 Apr 2016 17:01:27 -0400 From: Cole Robinson To: libvirt-list@redhat.com Date: Wed, 20 Apr 2016 17:01:22 -0400 Message-Id: <444830955dd0cf88a33dcb9546bf93add896c63d.1461186083.git.crobinso@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 1/2] qemu: process: split out shmem startup warning 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 Now we can return early and save some indentation --- src/qemu/qemu_process.c | 95 ++++++++++++++++++++++++++----------------------- 1 file changed, 51 insertions(+), 44 deletions(-) -- 2.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index c087300..10e1b5a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4497,6 +4497,56 @@ qemuProcessMakeDir(virQEMUDriverPtr driver, } +static void +qemuProcessStartWarnShmem(virDomainObjPtr vm) +{ + size_t i; + bool check_shmem = false; + bool shmem = vm->def->nshmems; + + /* + * For vhost-user to work, the domain has to have some type of + * shared memory configured. We're not the proper ones to judge + * whether shared hugepages or shm are enough and will be in the + * future, so we'll just warn in case neither is configured. + * Moreover failing would give the false illusion that libvirt is + * really checking that everything works before running the domain + * and not only we are unable to do that, but it's also not our + * aim to do so. + */ + for (i = 0; i < vm->def->nnets; i++) { + if (virDomainNetGetActualType(vm->def->nets[i]) == + VIR_DOMAIN_NET_TYPE_VHOSTUSER) { + check_shmem = true; + break; + } + } + + if (!check_shmem) + return; + + /* + * This check is by no means complete. We merely check + * whether there are *some* hugepages enabled and *some* NUMA + * nodes with shared memory access. + */ + if (!shmem && vm->def->mem.nhugepages) { + for (i = 0; i < virDomainNumaGetNodeCount(vm->def->numa); i++) { + if (virDomainNumaGetNodeMemoryAccessMode(vm->def->numa, i) == + VIR_NUMA_MEM_ACCESS_SHARED) { + shmem = true; + break; + } + } + } + + if (!shmem) { + VIR_WARN("Detected vhost-user interface without any shared memory, " + "the interface might not be operational"); + } +} + + /** * qemuProcessStartValidate: * @vm: domain object @@ -4517,9 +4567,6 @@ qemuProcessStartValidate(virQEMUDriverPtr driver, bool snapshot, unsigned int flags) { - bool check_shmem = false; - size_t i; - if (!(flags & VIR_QEMU_PROCESS_START_PRETEND)) { if (vm->def->virtType == VIR_DOMAIN_VIRT_KVM) { VIR_DEBUG("Checking for KVM availability"); @@ -4559,47 +4606,7 @@ qemuProcessStartValidate(virQEMUDriverPtr driver, VIR_DEBUG("Checking for any possible (non-fatal) issues"); - /* - * For vhost-user to work, the domain has to have some type of - * shared memory configured. We're not the proper ones to judge - * whether shared hugepages or shm are enough and will be in the - * future, so we'll just warn in case neither is configured. - * Moreover failing would give the false illusion that libvirt is - * really checking that everything works before running the domain - * and not only we are unable to do that, but it's also not our - * aim to do so. - */ - for (i = 0; i < vm->def->nnets; i++) { - if (virDomainNetGetActualType(vm->def->nets[i]) == - VIR_DOMAIN_NET_TYPE_VHOSTUSER) { - check_shmem = true; - break; - } - } - - if (check_shmem) { - bool shmem = vm->def->nshmems; - - /* - * This check is by no means complete. We merely check - * whether there are *some* hugepages enabled and *some* NUMA - * nodes with shared memory access. - */ - if (!shmem && vm->def->mem.nhugepages) { - for (i = 0; i < virDomainNumaGetNodeCount(vm->def->numa); i++) { - if (virDomainNumaGetNodeMemoryAccessMode(vm->def->numa, i) == - VIR_NUMA_MEM_ACCESS_SHARED) { - shmem = true; - break; - } - } - } - - if (!shmem) { - VIR_WARN("Detected vhost-user interface without any shared memory, " - "the interface might not be operational"); - } - } + qemuProcessStartWarnShmem(vm); return 0; }