From nobody Wed Apr 24 12:08:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580993680205728.2333346673296; Thu, 6 Feb 2020 04:54:40 -0800 (PST) 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-434-CiNpfaKDNlSNQDRqXjySMw-1; Thu, 06 Feb 2020 07:54:36 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B8183800EB2; Thu, 6 Feb 2020 12:54:31 +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 90B5160C05; Thu, 6 Feb 2020 12:54:31 +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 535FE18089CF; Thu, 6 Feb 2020 12:54:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 016CsOLn020528 for ; Thu, 6 Feb 2020 07:54:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6D8E25DA7E; Thu, 6 Feb 2020 12:54:24 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id E87225DA7D for ; Thu, 6 Feb 2020 12:54:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580993678; 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=3JQ+uWCE5TjiXhpb3zTINN9cMbtDkJyiqqjB7QQYF+g=; b=WMIq+ellRQj/Spyw/K7rd3Pma0jAxwfJs5aREmzoQkejuXrjBw0mTrqC+AbJJSCRjtauxl ND36IBCY5qjpgLun8eXfi1Dzs085TolHCYs03q1V4Wpo4YkpqpQJpGlOnsNSijPA4JlRSX q7GuFyi292AbUQcYM9hg4xInRW3icmg= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/4] qemuMonitorJSONBlockdevAdd: Refactor cleanup Date: Thu, 6 Feb 2020 13:54:16 +0100 Message-Id: <92009b135aeca5610ed09dff0a28f910542b8f41.1580993627.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.12 X-MC-Unique: CiNpfaKDNlSNQDRqXjySMw-1 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" Use automatic variable freeing and get rid of the cleanup section. Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor_json.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index dc1fc310ca..0d66f32887 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8811,25 +8811,19 @@ int qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon, virJSONValuePtr props) { - virJSONValuePtr cmd; - virJSONValuePtr reply =3D NULL; - int ret =3D -1; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; if (!(cmd =3D qemuMonitorJSONMakeCommandInternal("blockdev-add", props= ))) return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; - - ret =3D 0; + return -1; - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; + return 0; } --=20 2.24.1 From nobody Wed Apr 24 12:08:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580993684383628.2839043828922; Thu, 6 Feb 2020 04:54:44 -0800 (PST) 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-238-pLKIrp2uMFihsmNt7JpQgw-1; Thu, 06 Feb 2020 07:54:41 -0500 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 44600190B2B6; Thu, 6 Feb 2020 12:54:35 +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 10CCE5C1D8; Thu, 6 Feb 2020 12:54:35 +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 B134B18089D7; Thu, 6 Feb 2020 12:54:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 016CsPSQ020536 for ; Thu, 6 Feb 2020 07:54:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3D12C5DA7D; Thu, 6 Feb 2020 12:54:25 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id B94755DA7E for ; Thu, 6 Feb 2020 12:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580993683; 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=l5PqbdajPcT8583E8U8JsYWKzB4HvKAxq3o1c1OCX6Y=; b=JH3iSToouEgXJIN9gpmY+Aq/jyADrmrYU1Vm/QLgFPapSy4HOBVLgKZI93x7/uUAnMzrwJ MHMf96+cZ7MctXjsg43llZbNsiOjPHf91w2cXNHeGlU789j2emgPhfB8vh33RnkjDJavzg sqhvgrrDbQ9KEuT+y2bjVfu7F5FSB18= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/4] qemuMonitorJSONBlockdevDel: Refactor cleanup Date: Thu, 6 Feb 2020 13:54:17 +0100 Message-Id: <6fbbd420d309d60410fa156da50493f3d5cce870.1580993627.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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-MC-Unique: pLKIrp2uMFihsmNt7JpQgw-1 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" Use automatic variable freeing and get rid of the cleanup section. Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor_json.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 0d66f32887..95b5ab6968 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8831,9 +8831,8 @@ int qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon, const char *nodename) { - virJSONValuePtr cmd; - virJSONValuePtr reply =3D NULL; - int ret =3D -1; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; if (!(cmd =3D qemuMonitorJSONMakeCommand("blockdev-del", "s:node-name", nodename, @@ -8841,17 +8840,12 @@ qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon, return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; - - ret =3D 0; + return -1; - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; + return 0; } --=20 2.24.1 From nobody Wed Apr 24 12:08:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580993677736552.5794214054954; Thu, 6 Feb 2020 04:54:37 -0800 (PST) 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-370-wprUO9I9Nb-3uyKmtS9uEA-1; Thu, 06 Feb 2020 07:54:34 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8A495975AE; Thu, 6 Feb 2020 12:54:29 +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 60F5C8ECEF; Thu, 6 Feb 2020 12:54:29 +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 13820866A5; Thu, 6 Feb 2020 12:54:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 016CsQTV020543 for ; Thu, 6 Feb 2020 07:54:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1746E5DA81; Thu, 6 Feb 2020 12:54:26 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A9EF5DA7D for ; Thu, 6 Feb 2020 12:54:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580993676; 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=Vfk/QNXP56wYK0vKP17OgRONrgwiHtIW2n7mn5Vx6s8=; b=GXG6b208gtxtOpDI80VO4pmPi3+OXx5rBwRF7aUb/g4X6JTtSILc/3F1H2SIFb/r5/Ffur MuV0NlRW20HpO86eEAxCQrTeANdVuZs3DAnMBB+6iXPv01oUMM14j8FYysMzq5qs9ASjNW ATA73bzgCWhAA3L2oYOxlkdwVzKR/ng= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/4] qemuMonitorBlockdevAdd: Take double pointer argument Date: Thu, 6 Feb 2020 13:54:18 +0100 Message-Id: <23f001acc3a17d6fba3b74070a95921c3e84eb9c.1580993627.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.13 X-MC-Unique: wprUO9I9Nb-3uyKmtS9uEA-1 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" Modify qemuMonitorBlockdevAdd so that it takes a double pointer for the @props argument so that it's cleared inside the call. This allows writing cleaner callers. Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 14 ++------------ src/qemu/qemu_monitor.c | 16 ++++++---------- src/qemu/qemu_monitor.h | 2 +- src/qemu/qemu_monitor_json.c | 5 +++-- src/qemu/qemu_monitor_json.h | 2 +- 5 files changed, 13 insertions(+), 26 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 63116ef5f2..fa6c6f98e3 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1530,13 +1530,8 @@ static int qemuBlockStorageSourceAttachApplyStorage(qemuMonitorPtr mon, qemuBlockStorageSourceAttachDataP= tr data) { - int rv; - if (data->storageProps) { - rv =3D qemuMonitorBlockdevAdd(mon, data->storageProps); - data->storageProps =3D NULL; - - if (rv < 0) + if (qemuMonitorBlockdevAdd(mon, &data->storageProps) < 0) return -1; data->storageAttached =3D true; @@ -1563,13 +1558,8 @@ static int qemuBlockStorageSourceAttachApplyFormat(qemuMonitorPtr mon, qemuBlockStorageSourceAttachDataPt= r data) { - int rv; - if (data->formatProps) { - rv =3D qemuMonitorBlockdevAdd(mon, data->formatProps); - data->formatProps =3D NULL; - - if (rv < 0) + if (qemuMonitorBlockdevAdd(mon, &data->formatProps) < 0) return -1; data->formatAttached =3D true; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index ceedcd527a..463e24657a 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4390,23 +4390,19 @@ qemuMonitorBlockdevCreate(qemuMonitorPtr mon, * @mon: monitor object * @props: JSON object describing the blockdev to add * - * Adds a new block device (BDS) to qemu. Note that @props is always consu= med - * by this function and should not be accessed after calling this function. + * Adds a new block device (BDS) to qemu. Note that *@props is consumed + * and set to NULL on success. */ int qemuMonitorBlockdevAdd(qemuMonitorPtr mon, - virJSONValuePtr props) + virJSONValuePtr *props) { - VIR_DEBUG("props=3D%p (node-name=3D%s)", props, - NULLSTR(virJSONValueObjectGetString(props, "node-name"))); + VIR_DEBUG("props=3D%p (node-name=3D%s)", *props, + NULLSTR(virJSONValueObjectGetString(*props, "node-name"))); - QEMU_CHECK_MONITOR_GOTO(mon, error); + QEMU_CHECK_MONITOR(mon); return qemuMonitorJSONBlockdevAdd(mon, props); - - error: - virJSONValueFree(props); - return -1; } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index cca2cdcb27..6a6b8efaee 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1323,7 +1323,7 @@ int qemuMonitorBlockdevCreate(qemuMonitorPtr mon, virJSONValuePtr props); int qemuMonitorBlockdevAdd(qemuMonitorPtr mon, - virJSONValuePtr props); + virJSONValuePtr *props); int qemuMonitorBlockdevDel(qemuMonitorPtr mon, const char *nodename); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 95b5ab6968..815d17520a 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8809,12 +8809,13 @@ qemuMonitorJSONBlockdevCreate(qemuMonitorPtr mon, int qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon, - virJSONValuePtr props) + virJSONValuePtr *props) { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; + virJSONValuePtr pr =3D g_steal_pointer(props); - if (!(cmd =3D qemuMonitorJSONMakeCommandInternal("blockdev-add", props= ))) + if (!(cmd =3D qemuMonitorJSONMakeCommandInternal("blockdev-add", pr))) return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 61f5b0061d..fd2e09025e 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -597,7 +597,7 @@ int qemuMonitorJSONBlockdevCreate(qemuMonitorPtr mon, ATTRIBUTE_NONNULL(1); int qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon, - virJSONValuePtr props) + virJSONValuePtr *props) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon, --=20 2.24.1 From nobody Wed Apr 24 12:08:00 2024 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 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580993682909409.63284903461977; Thu, 6 Feb 2020 04:54:42 -0800 (PST) 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-175-0x0Ezs_UN2O6CiraHAyuGA-1; Thu, 06 Feb 2020 07:54:38 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 20A05801FA7; Thu, 6 Feb 2020 12:54:33 +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 EFD0C5DA7C; Thu, 6 Feb 2020 12:54:32 +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 AE29E18089D0; Thu, 6 Feb 2020 12:54:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 016CsQth020554 for ; Thu, 6 Feb 2020 07:54:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id D2BAA5DA89; Thu, 6 Feb 2020 12:54:26 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5AE515DA7D for ; Thu, 6 Feb 2020 12:54:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580993681; 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=L88HjTZMj4E9MYBxaDCb/jAXeYdJBtwqLyqn2IxFa5s=; b=RW/CBMyqznZnII9AkMuu04YyC9Wgylapb1bMGFLTLxYgcgfRDMW34tQUFijgatTxZaIvKi RSm383OncEmUqDigk/nxzIte9tzUqj6BEqFGBTDBHNB/cbknugzvkxFTiH0jXD6J7Q2d8C Qp79qJlePADZc/cyvPqZ3JeYeR4qD/M= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/4] qemu: hotplug: Fix handling of the 'copy-on-read' layer with blockdev Date: Thu, 6 Feb 2020 13:54:19 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.14 X-MC-Unique: 0x0Ezs_UN2O6CiraHAyuGA-1 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" My original implementation was completely broken because it attempted to use object-add/del instead of blockdev-add/del. https://bugzilla.redhat.com/show_bug.cgi?id=3D1798366 Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 39bcb70f83..c840889968 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -680,6 +680,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autoptr(virJSONValue) corProps =3D NULL; g_autofree char *corAlias =3D NULL; + bool corAdded =3D false; bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); if (qemuDomainStorageSourceChainAccessAllow(driver, vm, disk->src) < 0) @@ -692,9 +693,12 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, goto cleanup; if (blockdev) { - if (disk->copy_on_read =3D=3D VIR_TRISTATE_SWITCH_ON && - !(corProps =3D qemuBlockStorageGetCopyOnReadProps(disk))) - goto cleanup; + if (disk->copy_on_read =3D=3D VIR_TRISTATE_SWITCH_ON) { + if (!(corProps =3D qemuBlockStorageGetCopyOnReadProps(disk))) + goto cleanup; + + corAlias =3D g_strdup(QEMU_DOMAIN_DISK_PRIVATE(disk)->nodeCopy= OnRead); + } if (!(data =3D qemuBuildStorageSourceChainAttachPrepareBlockdev(di= sk->src, priv= ->qemuCaps))) @@ -719,9 +723,12 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, if (qemuBlockStorageSourceChainAttach(priv->mon, data) < 0) goto exit_monitor; - if (corProps && - qemuMonitorAddObject(priv->mon, &corProps, &corAlias) < 0) - goto exit_monitor; + if (corProps) { + if (qemuMonitorBlockdevAdd(priv->mon, &corProps) < 0) + goto exit_monitor; + + corAdded =3D true; + } if (qemuDomainAttachExtensionDevice(priv->mon, &disk->info) < 0) goto exit_monitor; @@ -763,8 +770,8 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, return ret; exit_monitor: - if (corAlias) - ignore_value(qemuMonitorDelObject(priv->mon, corAlias)); + if (corAdded) + ignore_value(qemuMonitorBlockdevDel(priv->mon, corAlias)); qemuBlockStorageSourceChainDetach(priv->mon, data); if (qemuDomainObjExitMonitor(driver, vm) < 0) @@ -4250,7 +4257,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, qemuDomainObjEnterMonitor(driver, vm); if (corAlias) - ignore_value(qemuMonitorDelObject(priv->mon, corAlias)); + ignore_value(qemuMonitorBlockdevDel(priv->mon, corAlias)); if (diskBackend) qemuBlockStorageSourceChainDetach(priv->mon, diskBackend); --=20 2.24.1