From nobody Thu May 16 15:53:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1657274112; cv=none; d=zohomail.com; s=zohoarc; b=b7bksRugiozZx+fQTKmNfKRf0Dfj4iEPtjKt6A0cwITZe9hH3VDzNDKlv2BnoSah2JuwrQg02cSegejUgH44Xc0Ect2CAiSd5blymKrfo4PFa1Xcs9jQOaj3RCwsWJ9K0QSlIO55JdwkOuwkjWEBh4iFvOXqrPzIpJTRcKP1iPE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657274112; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=Dl+qm4lBlmPy1SILLk4fSa4CR20MYsbbGJLgkJfC0eU=; b=lpnBUYbbYoNfw9B1cGGPWOMsvD68Y+2WZc7KoXB23x/GnBIf9G4zykw9dm4RMKxwZ2n3Wf8LQgyNpumtAxxC2iT0Xd9SoPBuRoiiiweVV0uhAMzOjmX9X31qsj7MmvMsJIOn8SOHGa2sODIjaBLldNbYzmPL5A/5o1j3KeDJqAY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1657274112252851.3009536918835; Fri, 8 Jul 2022 02:55:12 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-613-rq63l-HIN4S9IrNXszWbwQ-1; Fri, 08 Jul 2022 05:55:03 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 44CF185A584; Fri, 8 Jul 2022 09:55:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 315EA1121314; Fri, 8 Jul 2022 09:54:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DD4B6194706C; Fri, 8 Jul 2022 09:54:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 85341194704E for ; Wed, 6 Jul 2022 09:57:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 60B1BC28129; Wed, 6 Jul 2022 09:57:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5CCD1C23DBF for ; Wed, 6 Jul 2022 09:57:19 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 40E29185A7A4 for ; Wed, 6 Jul 2022 09:57:19 +0000 (UTC) Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-216-evpIeurfPsGGyXTR34VCBg-1; Wed, 06 Jul 2022 05:57:17 -0400 Received: by mail-pf1-f173.google.com with SMTP id a15so13893243pfv.13 for ; Wed, 06 Jul 2022 02:57:16 -0700 (PDT) Received: from localhost.localdomain ([103.20.128.80]) by smtp.gmail.com with ESMTPSA id m9-20020a17090a158900b001ef3daa0f21sm13810100pja.16.2022.07.06.02.57.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 02:57:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657274110; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Dl+qm4lBlmPy1SILLk4fSa4CR20MYsbbGJLgkJfC0eU=; b=a0YWHrO/8buNGx4loFneIlWpqGiQxMw6GH1yRtMBa0XoY2DKgFfH6gWqyPmo2++eD7PHGU eT3mUBFqgQrIqc9iyvYHj1aXOPr2zLqM6xgsQIU6u9vPjbeFsvLRCY0foX1P2bVYtX4ebR T3Gkn4ry9xZh8F8ptgs/tknuxDwpDlQ= X-MC-Unique: rq63l-HIN4S9IrNXszWbwQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: evpIeurfPsGGyXTR34VCBg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Dl+qm4lBlmPy1SILLk4fSa4CR20MYsbbGJLgkJfC0eU=; b=RcKofeaxAIkgl4sBYQB1VvuJNKzinitRukLgCyZMdDy2IHA6cuVE7uNBpTVb7Tz/AI CaTPONvaUmv0m/eNm08sWIDmq5nlMXRuoRSMZjBGHUndXchcJDMy2ObQcyNSuScGJTDl gNaSOP/tu0u23nFt6m2B3+szbjIvewuPvp+NljLFxGc2wst/uvkKxoiGKIOUwQpawNuI 1AX4PibeM1fxUTl5HsaDGc/GxCeKe6oXyXsYFLxsJOBGUVqFH50KGgwQaxDl0tx7yL3D OwV1mJNoG4twQdyJJL75LNLIz1jlkrl7fBWaJawaY6ewjPKE2EEHFOYgoxyzM0ZlDmt1 kyeg== X-Gm-Message-State: AJIora8XbNOrD/jC5n72KKFCFiJA2X//orug0hVOU0DFDztB/fw9j8OI +e4dbA58vLYS41BQv/8SNJSgZEgV8L0HOjDTJ3yBG6xKucE= X-Google-Smtp-Source: AGRyM1uFXWjbDVR2wPW5DUDd0QquapYkMeO+dvTqImSAVLPLyO3Yjr4+pYanGLiLFtPH/dunE+TgxA== X-Received: by 2002:a05:6a00:23c1:b0:525:4886:4083 with SMTP id g1-20020a056a0023c100b0052548864083mr47705784pfc.10.1657101435326; Wed, 06 Jul 2022 02:57:15 -0700 (PDT) From: "minglei.liu" To: libvir-list@redhat.com Subject: [PATCH] qemu: support hotplug cdrom with usb/scsi bus Date: Wed, 6 Jul 2022 02:57:10 -0700 Message-Id: <20220706095710.498385-1-minglei.liu@smartx.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mailman-Approved-At: Fri, 08 Jul 2022 09:54:56 +0000 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "minglei.liu" Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1657274114192100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Qemu support hotplug cdrom device with usb or scsi bus, just unblock these devices in qemuDomainAttachDeviceDiskLiveInternal and qemuDomainDetachPrepDisk. Fixes: #261 Signed-off-by: minglei.liu Reviewed-by: Michal Privoznik --- src/qemu/qemu_hotplug.c | 13 +++- tests/qemuhotplugtest.c | 18 ++++++ .../qemuhotplug-cdrom-scsi.xml | 6 ++ .../qemuhotplug-cdrom-usb.xml | 6 ++ .../qemuhotplug-base-live+cdrom-scsi.xml | 60 +++++++++++++++++++ .../qemuhotplug-base-live+cdrom-usb.xml | 60 +++++++++++++++++++ 6 files changed, 160 insertions(+), 3 deletions(-) create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-cdrom-scsi.xml create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-cdrom-usb.xml create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-live+cdro= m-scsi.xml create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-live+cdro= m-usb.xml diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 27e68370cf..d917086023 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -992,10 +992,9 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *= driver, bool releaseSeclabel =3D false; int ret =3D -1; =20 - if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM || - disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY) { + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("cdrom/floppy device hotplug isn't supported")); + _("floppy device hotplug isn't supported")); return -1; } =20 @@ -1025,6 +1024,10 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver= *driver, break; =20 case VIR_DOMAIN_DISK_BUS_VIRTIO: + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("cdrom device with virtio bus isn't supported")); + } if (qemuDomainEnsureVirtioAddress(&releaseVirtio, vm, dev) < 0) goto cleanup; break; @@ -5414,6 +5417,10 @@ qemuDomainDetachPrepDisk(virDomainObj *vm, =20 case VIR_DOMAIN_DISK_DEVICE_CDROM: case VIR_DOMAIN_DISK_DEVICE_FLOPPY: + if ((virDomainDiskBus) disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_USB || + (virDomainDiskBus) disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_SCSI) { + break; + } virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("disk device type '%s' cannot be detached"), virDomainDiskDeviceTypeToString(disk->device)); diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index e98d9845e8..3c9dac241a 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -860,6 +860,24 @@ mymain(void) DO_TEST_DETACH("base-live", "guestfwd", false, false, "netdev_del", QMP_OK); =20 + DO_TEST_ATTACH("base-live", "cdrom-usb", false, true, + "human-monitor-command", HMP("OK\\r\\n"), + "device_add", QMP_OK); + DO_TEST_DETACH("base-live", "cdrom-usb", true, true, + "device_del", QMP_OK); + DO_TEST_DETACH("base-live", "cdrom-usb", false, false, + "device_del", QMP_DEVICE_DELETED("usb-disk4") QMP_OK, + "human-monitor-command", HMP("")); + + DO_TEST_ATTACH("base-live", "cdrom-scsi", false, true, + "human-monitor-command", HMP("OK\\r\\n"), + "device_add", QMP_OK); + DO_TEST_DETACH("base-live", "cdrom-scsi", true, true, + "device_del", QMP_OK); + DO_TEST_DETACH("base-live", "cdrom-scsi", false, false, + "device_del", QMP_DEVICE_DELETED("scsi0-0-0-4") QMP_OK, + "human-monitor-command", HMP("")); + #define DO_TEST_CPU_GROUP(prefix, vcpus, modernhp, expectfail) \ do { \ cpudata.test =3D prefix; \ diff --git a/tests/qemuhotplugtestdevices/qemuhotplug-cdrom-scsi.xml b/test= s/qemuhotplugtestdevices/qemuhotplug-cdrom-scsi.xml new file mode 100644 index 0000000000..da8b94bb22 --- /dev/null +++ b/tests/qemuhotplugtestdevices/qemuhotplug-cdrom-scsi.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/qemuhotplugtestdevices/qemuhotplug-cdrom-usb.xml b/tests= /qemuhotplugtestdevices/qemuhotplug-cdrom-usb.xml new file mode 100644 index 0000000000..efb974090c --- /dev/null +++ b/tests/qemuhotplugtestdevices/qemuhotplug-cdrom-usb.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+cdrom-scsi.= xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+cdrom-scsi.xml new file mode 100644 index 0000000000..c3242a582f --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+cdrom-scsi.xml @@ -0,0 +1,60 @@ + + hotplug + d091ea82-29e6-2e34-3005-f02617b36e87 + 4194304 + 4194304 + 4 + + hvm + + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + + + + + + + +
+ + + +
+ + + +
+ + + +
+ + + + + + +
+ + + + + + + +