From nobody Fri Dec 19 17:38:47 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588767011; cv=none; d=zohomail.com; s=zohoarc; b=h//O4xh91bINhRuJSVgN4TfS/ogNsOdNcRbp7g1bw+S0T9S5PJLhOYPZtFyvfdQ+YS6Zc9Xa6+WlRtECIZ99I/TgoqHNAUvqKOIQHIVYG5/QKDBsx7cAhPdCZqsJqdvjke5n2DPleuijhEoWv2ndzTkPZvBF8kXZ1b3piAG4p7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588767011; h=Content-Type:Content-Transfer-Encoding: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; bh=yR5vMQkGYXWutTGgkskVTxsvoLwMCqIDqJwtwY9NhRA=; b=hTlIlHKQBQKHg7rhTD7ozwnrphvXyM8c352sfOakVVYYjlPhUh+WUM6hHw/6WwHGoFM5jt3FresZyTrIg3W00xfEmYzTo/w0gkyWDVz8aly+8ITs3DWbYxFOCvYniOpxi3SjbPfuWMcuWv9LXNBCqh1lHFQ/m92q/wtD88B08rc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1588767011379762.3173944922787; Wed, 6 May 2020 05:10:11 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-6-n8c5uO-jNtGATcDPgSAMJA-1; Wed, 06 May 2020 08:09:01 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 79447102C7F2; Wed, 6 May 2020 12:08:54 +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 4DA885C1D6; Wed, 6 May 2020 12:08:54 +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 0B27954D05; Wed, 6 May 2020 12:08:54 +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 046C8qEh029639 for ; Wed, 6 May 2020 08:08:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id A72565C1D4; Wed, 6 May 2020 12:08:52 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19EA85C1BD for ; Wed, 6 May 2020 12:08:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588767006; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=yR5vMQkGYXWutTGgkskVTxsvoLwMCqIDqJwtwY9NhRA=; b=LQvUnI/SVEalXm5Eq8dUsBGjMuyiAGrqWP9dIenYU+isjOOscZeWQ1wgXDk6fYZUy+SJyM PZJOgMTHwOMr50SS0Sg3DyCFQnqxLvuSpP2tvFBUAwimn+4ySGSHxJ7xzxcEbVdFQaAbYO dCfQmMbPfcx0J+PeRe7PH/EVAdm3V1g= X-MC-Unique: n8c5uO-jNtGATcDPgSAMJA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/20] qemuBuildDiskCommandLine: Clarify logic around building -device for disks Date: Wed, 6 May 2020 14:08:23 +0200 Message-Id: <5874904fe4640551f90db7bd3cfa45352d003c8c.1588766791.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" For 'SD' disks and floppies in the pre-blockdev era we don't format -device. Extract the logic so that it's more clear and add comments. Signed-off-by: Peter Krempa --- src/qemu/qemu_command.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1b3651a758..3f3e3b69a8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2158,20 +2158,26 @@ qemuBuildDiskCommandLine(virCommandPtr cmd, if (qemuBuildDiskSourceCommandLine(cmd, disk, qemuCaps) < 0) return -1; - if (!qemuDiskBusIsSD(disk->bus)) { - if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_FDC || - virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) { - if (qemuCommandAddExtDevice(cmd, &disk->info) < 0) - return -1; + /* SD cards are currently instantiated via -drive if=3Dsd, so the -dev= ice + * part must be skipped */ + if (qemuDiskBusIsSD(disk->bus)) + return 0; - virCommandAddArg(cmd, "-device"); + /* floppy devices are instantiated via -drive ...,if=3Dnone and bound = to the + * controller via -global isa-fdc.driveA/B options in the pre-blockdev= era */ + if (disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_FDC && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) + return 0; - if (!(optstr =3D qemuBuildDiskDeviceStr(def, disk, bootindex, - qemuCaps))) - return -1; - virCommandAddArg(cmd, optstr); - } - } + if (qemuCommandAddExtDevice(cmd, &disk->info) < 0) + return -1; + + virCommandAddArg(cmd, "-device"); + + if (!(optstr =3D qemuBuildDiskDeviceStr(def, disk, bootindex, + qemuCaps))) + return -1; + virCommandAddArg(cmd, optstr); return 0; } --=20 2.26.2