From patchwork Fri Jul 14 23:43:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 107834 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1556177qge; Fri, 14 Jul 2017 16:43:19 -0700 (PDT) X-Received: by 10.55.6.82 with SMTP id 79mr506151qkg.145.1500075799506; Fri, 14 Jul 2017 16:43:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500075799; cv=none; d=google.com; s=arc-20160816; b=ecUCB+twnbaZIg5sjFNxCM1+spfmcgR3DEMg+zZQ/iY86kb78zhgDDV46kPjsqoXg0 T3aa7u+dLa47IYaCpgL+SpZ9JsxDk2Cz0ZevJOrV1k4D4ub5hdlwB34f4d1ZEJ1eDgXi Ohstqmxo+mPBZ050foezwNKGoywwlaI2vmin9d9Tq7acTba5X6Bg8PVMEUc4NKFSwCTu zIUFohKm5FD9dTkLIoeccavOIEVUyi/Z+BMRd8ksessxGtujSMP0l6bhlhCC5WyoMB6Z ZvDVS2l8HwRfTKo0dwUyU2j1QAuJB39v7DNzdq2024/GjNHalkKkWzkNfen0DDW1nFb+ p5hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:references :in-reply-to:message-id:date:to:from:delivered-to:dkim-filter :dmarc-filter:arc-authentication-results; bh=E1tV5AFWZnsZ7BOIhZDpb2yjP2wUx9hrRkVXLEUvJ8E=; b=ANuw+joXmH4Ztsk1ZlWgF1HrbXSsqxy8/ojimCFpcFYxPEaPLYPb3vR9OO8150ppsl 0R3KMebmiyllu4zj/SbzdI7G5Qv8+vohHPt6zPHyHoCK57/iN64ssQ8D1Oz4XYpN/P9c 07I/uSGNMPxb3tiAh7+i0BT4BehItTD1nVjg7ktRmRwBUlPL1ZLP/1Uzw7X4vDTw1tMj IVvWrozcUZt+zpMecHk3OqZ3IdLIJpSQo6Z6o03ESTgPxAorYB+MUimOQr4yecpQzG4z HwFb+xmamhlWAB4/IY/pGe4TdFqnNmTGs1CKyek1VLKH+82XACRGOVZS4v1iNgvpj/Gr wr8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id u2si8826778qkh.392.2017.07.14.16.43.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jul 2017 16:43:19 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 DAE1FC049D59; Fri, 14 Jul 2017 23:43:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DAE1FC049D59 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.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 DAE1FC049D59 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 685AB6BF84; Fri, 14 Jul 2017 23:43:17 +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 A1CD81803B26; Fri, 14 Jul 2017 23:43:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6ENhEwW023228 for ; Fri, 14 Jul 2017 19:43:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id B72471840D; Fri, 14 Jul 2017 23:43:14 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from colepc.redhat.com (ovpn-116-206.phx2.redhat.com [10.3.116.206]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D42318398; Fri, 14 Jul 2017 23:43:14 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Fri, 14 Jul 2017 19:43:06 -0400 Message-Id: <6a8b5ec69544b9f2582b8b38e3bab1127da6358d.1500075702.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] qemu: command: explicitly error for non-x86 default CPU 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 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.31]); Fri, 14 Jul 2017 23:43:18 +0000 (UTC) The code only currently handles writing an x86 default -cpu argument, and doesn't know anything about other architectures. Let's make this explicit rather than leaving ex. qemu ppc64 to throw an error about -cpu qemu64 Signed-off-by: Cole Robinson --- src/qemu/qemu_command.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) -- 2.13.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index aa12479f7..f727e3d30 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6716,17 +6716,11 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, virArch hostarch = virArchFromHost(); char *cpu = NULL, *cpu_flags = NULL; bool hasHwVirt = false; - const char *default_model; int ret = -1; virBuffer cpu_buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER; size_t i; - if (def->os.arch == VIR_ARCH_I686) - default_model = "qemu32"; - else - default_model = "qemu64"; - if (def->cpu && (def->cpu->mode != VIR_CPU_MODE_CUSTOM || def->cpu->model)) { if (qemuBuildCpuModelArgStr(driver, def, &cpu_buf, qemuCaps) < 0) @@ -6768,7 +6762,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, ((hostarch == VIR_ARCH_X86_64 && strstr(def->emulator, "kvm")) || strstr(def->emulator, "x86_64"))) { - virBufferAdd(&cpu_buf, default_model, -1); + virBufferAddLit(&cpu_buf, "qemu32"); } } @@ -6915,6 +6909,23 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, cpu_flags = virBufferContentAndReset(&buf); if (cpu_flags && !cpu) { + const char *default_model; + + switch (def->os.arch) { + case VIR_ARCH_I686: + default_model = "qemu32"; + break; + case VIR_ARCH_X86_64: + default_model = "qemu64"; + break; + default: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("CPU flags requested but can't determine " + "default CPU for arch %s"), + virArchToString(def->os.arch)); + goto cleanup; + } + if (VIR_STRDUP(cpu, default_model) < 0) goto cleanup; }