From nobody Mon Feb 9 01:16:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1629463668054992.0711115323387; Fri, 20 Aug 2021 05:47:48 -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-123-EuoJCW0UO82J5L6AdeFpdg-1; Fri, 20 Aug 2021 08:47:45 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9D6E7802935; Fri, 20 Aug 2021 12:47:40 +0000 (UTC) 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 7524D10013C1; Fri, 20 Aug 2021 12:47:40 +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 3B7A4181A3F4; Fri, 20 Aug 2021 12:47:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17KCjHg3013700 for ; Fri, 20 Aug 2021 08:45:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7D6CD20BEAB6; Fri, 20 Aug 2021 12:45:17 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7895920B665E for ; Fri, 20 Aug 2021 12:45:14 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (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 5CA0C106668A for ; Fri, 20 Aug 2021 12:45:14 +0000 (UTC) Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-418-0MWx8h5zMJKxVaOImgrzQQ-1; Fri, 20 Aug 2021 08:45:12 -0400 Received: by mail-pj1-f47.google.com with SMTP id oc2-20020a17090b1c0200b00179e56772d6so3817988pjb.4 for ; Fri, 20 Aug 2021 05:45:12 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id c16sm6945183pfb.196.2021.08.20.05.45.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 05:45:10 -0700 (PDT) X-MC-Unique: EuoJCW0UO82J5L6AdeFpdg-1 X-MC-Unique: 0MWx8h5zMJKxVaOImgrzQQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+Ipafn15jeyql9YBYl7Z1Omy+R6Om0k84Zzrw5obRWE=; b=DMO/ZqTicIFAk2x/U+eOVFArQqAcAruQbox9Xtld5riXmljG1NNAmCrcaGncu4W+yp hla4rH/VhD2VdAkgKEu5n+nAhIbc/LjtEFJi1QTe63GnUMBA/B4CduXLxfWMbf7Vvaf7 jNFFTUmmCtZykBcLkIbOJxKc1YMUaCwIp8k9xik/ZFuuWk8a3BpJMOCJTTQII7r2feOP JVaKmqTQh1AvU04Tih4ArcCvoOya3Lg4HchpdZNrGYfeUlD594+pFniigrmfdPEaEZzg CaPNNW0AUYrgX6o3WutuXRWMLUxIziAe304LiQ+5u7rrFCbO4sCeyJOPzgC1PFds28xT itNg== X-Gm-Message-State: AOAM5338Jptk+v2oWt3SB8rjkDdh/Qrwbgb9oqjv20uZFgOPoESAyi6j dkzhrcru7iGuXg7IjylQF/ER4Zs4O2p+RM8fAl8= X-Google-Smtp-Source: ABdhPJx55ibDrwxwT5d16n3/iHtEZd7QFBT15v0PB8t4KXLCg+4/rgEL38J82CYcHUtDlN9mjYi0BA== X-Received: by 2002:a17:90a:ba93:: with SMTP id t19mr4658238pjr.4.1629463511051; Fri, 20 Aug 2021 05:45:11 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 09/12] test_driver: add memballoon support for testDomainDetachDeviceLiveAndConfig Date: Fri, 20 Aug 2021 20:44:36 +0800 Message-Id: <20210820124439.535276-10-lukedyue@gmail.com> In-Reply-To: <20210820124439.535276-1-lukedyue@gmail.com> References: <20210820124439.535276-1-lukedyue@gmail.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.78 on 10.11.54.4 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.84 on 10.5.11.22 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-ZM-MESSAGEID: 1629463669293100001 Content-Type: text/plain; charset="utf-8" As the memballoon device shouldn't be hot-(un)pluggable, so error if try to remove it on a running domain, for removing from config, it's fine. Signed-off-by: Luke Yue --- src/hypervisor/domain_driver.c | 18 ++++++++++++++++++ src/hypervisor/domain_driver.h | 3 +++ src/libvirt_private.syms | 1 + src/test/test_driver.c | 19 ++++++++++++++++--- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index 93754ae08a..34e225dd2d 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -797,3 +797,21 @@ virDomainDriverDetachTPMDeviceConfig(virDomainDef *vmd= ef, =20 return 0; } + + +int +virDomainDriverDetachMemballoonDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev) +{ + if (!vmdef->memballoon || + !virDomainMemballoonDefEquals(dev->data.memballoon, + vmdef->memballoon)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("matching memballoon device not found")); + return -1; + } + virDomainMemballoonDefFree(vmdef->memballoon); + vmdef->memballoon =3D NULL; + + return 0; +} diff --git a/src/hypervisor/domain_driver.h b/src/hypervisor/domain_driver.h index 6cb9defb58..4d8b1f7b36 100644 --- a/src/hypervisor/domain_driver.h +++ b/src/hypervisor/domain_driver.h @@ -104,3 +104,6 @@ int virDomainDriverDetachVsockDeviceConfig(virDomainDef= *vmdef, =20 int virDomainDriverDetachTPMDeviceConfig(virDomainDef *vmdef, virDomainDeviceDef *dev); + +int virDomainDriverDetachMemballoonDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 57f0d24c36..fc4e8736b0 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1543,6 +1543,7 @@ virDomainDriverDetachFSDeviceConfig; virDomainDriverDetachHostdevDeviceConfig; virDomainDriverDetachInputDeviceConfig; virDomainDriverDetachLeaseDeviceConfig; +virDomainDriverDetachMemballoonDeviceConfig; virDomainDriverDetachMemoryDeviceConfig; virDomainDriverDetachNetDeviceConfig; virDomainDriverDetachRedirdevDeviceConfig; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index c12a76749c..bf26df0d18 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9539,7 +9539,8 @@ testDomainGetMessages(virDomainPtr dom, =20 static int testDomainDetachDeviceLiveAndConfig(virDomainDef *vmdef, - virDomainDeviceDef *dev) + virDomainDeviceDef *dev, + unsigned int flags) { virDomainChrDef *chr; =20 @@ -9641,11 +9642,23 @@ testDomainDetachDeviceLiveAndConfig(virDomainDef *v= mdef, =20 break; =20 + case VIR_DOMAIN_DEVICE_MEMBALLOON: + if (flags & VIR_DOMAIN_AFFECT_LIVE) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("detach of device '%s' on running domain " + "is not supported"), + virDomainDeviceTypeToString(dev->type)); + return -1; + } else { + if (virDomainDriverDetachMemballoonDeviceConfig(vmdef, dev) < = 0) + return -1; + } + break; + case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_GRAPHICS: case VIR_DOMAIN_DEVICE_HUB: case VIR_DOMAIN_DEVICE_SMARTCARD: - case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_PANIC: @@ -9711,7 +9724,7 @@ testDomainChgDevice(virDomainPtr dom, break; =20 case VIR_DOMAIN_DEVICE_ACTION_DETACH: - if (testDomainDetachDeviceLiveAndConfig(def, dev) < 0) + if (testDomainDetachDeviceLiveAndConfig(def, dev, flags) < 0) goto cleanup; break; =20 --=20 2.33.0