From nobody Sun May 5 11:54:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=163.com ARC-Seal: i=1; a=rsa-sha256; t=1676861902; cv=none; d=zohomail.com; s=zohoarc; b=FEOT+waqNOxheE9tPp/NwRLYEa8h7Qmw0RsqFsYw4SnEWDfLww30mV+MfFKW4nmc91inGaCjyqzGHL++fw2RTQmoKV5Sg8SZpfKwivgYbTuaZAMp4lhogzNwfKxHG5UTAn4Q/HvLig7zGUovYXK6YVvLfqwW8GU4S0VP9MdgUXk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676861902; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=hcXPp+IfHxMTdWEg/GEkFJuLynS1E9U7SkVycDUEW5E=; b=YM8d+QwzO+9tBujSf4EZ8vVtC09Z1Ou+HDNJEhBsztgoP8jVjq6Rq/BIcFAGDKcRkqO6beS8nP+d/mS9lAWFermBVwv4mPg5NnwhousVSWfKCxQ0gxhcpr4R85Eehv3W04GtFH/NtxzPrXInXRBdgU75q8BjX6mqnTPee3S1lK4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1676861902934711.4162741846167; Sun, 19 Feb 2023 18:58:22 -0800 (PST) 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-372-pBHjIOCTP0a1slr_An5jeg-1; Sun, 19 Feb 2023 21:58:16 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CA66E80D0E8; Mon, 20 Feb 2023 02:58:14 +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 B63A12026D4B; Mon, 20 Feb 2023 02:58:14 +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 8810D1946588; Mon, 20 Feb 2023 02:58:14 +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 B7CCB1946588 for ; Mon, 20 Feb 2023 02:58:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AB26FC16022; Mon, 20 Feb 2023 02:58:13 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast10.extmail.prod.ext.rdu2.redhat.com [10.11.55.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9C762C16023 for ; Mon, 20 Feb 2023 02:58:13 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 8076A1C05EC7 for ; Mon, 20 Feb 2023 02:58:13 +0000 (UTC) Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.196]) by relay.mimecast.com with ESMTP id us-mta-117-AlZhKr3KM8i97JrySYVNtg-1; Sun, 19 Feb 2023 21:58:11 -0500 Received: from localhost.localdomain (unknown [113.128.80.191]) by zwqz-smtp-mta-g4-3 (Coremail) with SMTP id _____wBHw2C14fJj5azQAQ--.56057S3; Mon, 20 Feb 2023 10:58:06 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676861902; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:content-type:content-type: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=hcXPp+IfHxMTdWEg/GEkFJuLynS1E9U7SkVycDUEW5E=; b=c1WG6mQP0Up6Qkx98lhAuoJRj5EStmYh/pjV9E50TaOJh2TBICcQe9H+LzrQcEvIoFaWiy FKTIm2rvYBMbbwhYwx5+FEg5PV14o+EJ9QdHQX8F7DGDgmZiivY3LvEks9dH/h/VNFPgoy 8s6Urm+5osDuLFdTUVRZoPv+Yl+aHw8= X-MC-Unique: pBHjIOCTP0a1slr_An5jeg-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: AlZhKr3KM8i97JrySYVNtg-1 From: jshen28 To: libvirt-list@redhat.com Subject: [PATCH 1/1] WIP: allow update more disk properties Date: Mon, 20 Feb 2023 10:57:55 +0800 Message-Id: <20230220025755.29725-2-yshxxsjt715@163.com> In-Reply-To: <20230220025755.29725-1-yshxxsjt715@163.com> References: <20230220025755.29725-1-yshxxsjt715@163.com> X-CM-TRANSID: _____wBHw2C14fJj5azQAQ--.56057S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxZF4xGr1kXw48Gw1kGF1UAwb_yoW5uF4DpF s3Aw1kAF45Zr47ZFs7Ga17ZF1Fg3yUXr1DKF4agwnYqrW3Xa1DXr1Syry8uF1DJrZxAr9r ury7Ja9093Z7taDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jcDGnUUUUU= X-Originating-IP: [113.128.80.191] X-CM-SenderInfo: h1vk555vmwliqv6rljoofrz/1tbiWRMcL1WByE32LAAAsy 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 3.1 on 10.11.54.8 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: ushen Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 2 X-Mimecast-Originator: redhat.com X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1676861903772100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8"; x-default="true" From: ushen --- src/qemu/qemu_block.c | 2 +- src/qemu/qemu_block.h | 5 +++++ src/qemu/qemu_domain.c | 2 -- src/qemu/qemu_driver.c | 17 +++++++++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 5e700eff99..778aeebb8f 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -2981,7 +2981,7 @@ qemuBlockReopenFormatMon(qemuMonitor *mon, * that @src must be already properly configured for the desired outcome. = The * nodenames of @src are used to identify the specific image in qemu. */ -static int +int qemuBlockReopenFormat(virDomainObj *vm, virStorageSource *src, virDomainAsyncJob asyncJob) diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 5a61a19da2..9ef692278d 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -245,6 +245,11 @@ int qemuBlockReopenFormatMon(qemuMonitor *mon, virStorageSource *src); =20 +int +qemuBlockReopenFormat(virDomainObj *vm, + virStorageSource *src, + virDomainAsyncJob asyncJob); + int qemuBlockReopenReadWrite(virDomainObj *vm, virStorageSource *src, diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e9bc0f375d..e5b5fef87e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8239,7 +8239,6 @@ qemuDomainDiskChangeSupported(virDomainDiskDef *disk, CHECK_STREQ_NULLABLE(product, "product"); =20 - CHECK_EQ(cachemode, "cache", true); CHECK_EQ(error_policy, "error_policy", true); CHECK_EQ(rerror_policy, "rerror_policy", true); CHECK_EQ(iomode, "io", true); @@ -8267,7 +8266,6 @@ qemuDomainDiskChangeSupported(virDomainDiskDef *disk, CHECK_EQ(info.bootIndex, "boot order", true); CHECK_EQ(rawio, "rawio", true); CHECK_EQ(sgio, "sgio", true); - CHECK_EQ(discard, "discard", true); CHECK_EQ(iothread, "iothread", true); =20 CHECK_STREQ_NULLABLE(domain_name, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6154fe9bfe..bcb68d6c66 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6802,6 +6802,7 @@ qemuDomainChangeDiskLive(virDomainObj *vm, virDomainDiskDef *orig_disk =3D NULL; virDomainStartupPolicy origStartupPolicy; virDomainDeviceDef oldDev =3D { .type =3D dev->type }; + int ret; =20 if (!(orig_disk =3D virDomainDiskByTarget(vm->def, disk->dst))) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -6840,6 +6841,22 @@ qemuDomainChangeDiskLive(virDomainObj *vm, } =20 dev->data.disk->src =3D NULL; + } else { + // reopen disk device with more parameters + disk->src->backingStore =3D orig_disk->src->backingStore; + ret =3D qemuBlockReopenFormat(vm, disk->src, false); + disk->src->backingStore =3D NULL; + if (!ret) { + orig_disk->cachemode =3D disk->cachemode; + orig_disk->src->cachemode =3D disk->src->cachemode; + orig_disk->detect_zeroes =3D disk->detect_zeroes; + orig_disk->src->detect_zeroes =3D disk->src->detect_zeroes; + orig_disk->discard =3D disk->discard; + orig_disk->src->discard =3D disk->src->discard; + disk->src->backingStore =3D NULL; + } else { + return ret; + } } =20 /* in case when we aren't updating disk source we update startup polic= y here */ --=20 2.17.1