From nobody Thu Nov 6 14:05:17 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489416998373581.2030359238826; Mon, 13 Mar 2017 07:56:38 -0700 (PDT) Received: from localhost ([::1]:52494 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnROn-0005oR-4g for importer@patchew.org; Mon, 13 Mar 2017 10:56:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRNa-0005eS-Rb for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnRNZ-0002rR-UI for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56028) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnRNV-0002pv-NU; Mon, 13 Mar 2017 10:55:17 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BF0287E9F9; Mon, 13 Mar 2017 14:55:17 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-150.ams2.redhat.com [10.36.117.150]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2DEtEUT009408; Mon, 13 Mar 2017 10:55:16 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 13 Mar 2017 15:54:57 +0100 Message-Id: <1489416908-3771-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1489416908-3771-1-git-send-email-kwolf@redhat.com> References: <1489416908-3771-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 13 Mar 2017 14:55:17 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/12] backup: allow target without .bdrv_get_info X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Currently backup to nbd target is broken, as nbd doesn't have .bdrv_get_info realization. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/backup.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/block/backup.c b/block/backup.c index d1ab617..d3d20db 100644 --- a/block/backup.c +++ b/block/backup.c @@ -24,6 +24,7 @@ #include "qemu/cutils.h" #include "sysemu/block-backend.h" #include "qemu/bitmap.h" +#include "qemu/error-report.h" =20 #define BACKUP_CLUSTER_SIZE_DEFAULT (1 << 16) #define SLICE_TIME 100000000ULL /* ns */ @@ -648,7 +649,16 @@ BlockJob *backup_job_create(const char *job_id, BlockD= riverState *bs, * backup cluster size is smaller than the target cluster size. Even f= or * targets with a backing file, try to avoid COW if possible. */ ret =3D bdrv_get_info(target, &bdi); - if (ret < 0 && !target->backing) { + if (ret =3D=3D -ENOTSUP && !target->backing) { + /* Cluster size is not defined */ + error_report("WARNING: The target block device doesn't provide " + "information about the block size and it doesn't have= a " + "backing file. The default block size of %u bytes is " + "used. If the actual block size of the target exceeds= " + "this default, the backup may be unusable", + BACKUP_CLUSTER_SIZE_DEFAULT); + job->cluster_size =3D BACKUP_CLUSTER_SIZE_DEFAULT; + } else if (ret < 0 && !target->backing) { error_setg_errno(errp, -ret, "Couldn't determine the cluster size of the target image, " "which has no backing file"); --=20 1.8.3.1 From nobody Thu Nov 6 14:05:17 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489417274666224.68422933000227; Mon, 13 Mar 2017 08:01:14 -0700 (PDT) Received: from localhost ([::1]:52522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRTD-0001JN-C9 for importer@patchew.org; Mon, 13 Mar 2017 11:01:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRNb-0005fC-8B for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnRNa-0002rX-0K for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50948) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnRNX-0002qA-0V; Mon, 13 Mar 2017 10:55:19 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 19D4BD1FEE; Mon, 13 Mar 2017 14:55:19 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-150.ams2.redhat.com [10.36.117.150]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2DEtEUU009408; Mon, 13 Mar 2017 10:55:18 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 13 Mar 2017 15:54:58 +0100 Message-Id: <1489416908-3771-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1489416908-3771-1-git-send-email-kwolf@redhat.com> References: <1489416908-3771-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 13 Mar 2017 14:55:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 02/12] file-posix: Consider max_segments for BlockLimits.max_transfer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fam Zheng BlockLimits.max_transfer can be too high without this fix, guest will encounter I/O error or even get paused with werror=3Dstop or rerror=3Dstop.= The cause is explained below. Linux has a separate limit, /sys/block/.../queue/max_segments, which in the worst case can be more restrictive than the BLKSECTGET which we already consider (note that they are two different things). So, the failure scenario before this patch is: 1) host device has max_sectors_kb =3D 4096 and max_segments =3D 64; 2) guest learns max_sectors_kb limit from QEMU, but doesn't know max_segments; 3) guest issues e.g. a 512KB request thinking it's okay, but actually it's not, because it will be passed through to host device as an SG_IO req that has niov > 64; 4) host kernel doesn't like the segmenting of the request, and returns -EINVAL; This patch checks the max_segments sysfs entry for the host device and calculates a "conservative" bytes limit using the page size, which is then merged into the existing max_transfer limit. Guest will discover this from the usual virtual block device interfaces. (In the case of scsi-generic, it will be done in the INQUIRY reply interception in device model.) The other possibility is to actually propagate it as a separate limit, but it's not better. On the one hand, there is a big complication: the limit is per-LUN in QEMU PoV (because we can attach LUNs from different host HBAs to the same virtio-scsi bus), but the channel to communicate it in a per-LUN manner is missing down the stack; on the other hand, two limits versus one doesn't change much about the valid size of I/O (because guest has no control over host segmenting). Also, the idea to fall back to bounce buffering in QEMU, upon -EINVAL, was explored. Unfortunately there is no neat way to ensure the bounce buffer is less segmented (in terms of DMA addr) than the guest buffer. Practically, this bug is not very common. It is only reported on a Emulex (lpfc), so it's okay to get it fixed in the easier way. Reviewed-by: Paolo Bonzini Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- block/file-posix.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/block/file-posix.c b/block/file-posix.c index 4de1abd..c4c0663 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -668,6 +668,48 @@ static int hdev_get_max_transfer_length(BlockDriverSta= te *bs, int fd) #endif } =20 +static int hdev_get_max_segments(const struct stat *st) +{ +#ifdef CONFIG_LINUX + char buf[32]; + const char *end; + char *sysfspath; + int ret; + int fd =3D -1; + long max_segments; + + sysfspath =3D g_strdup_printf("/sys/dev/block/%u:%u/queue/max_segments= ", + major(st->st_rdev), minor(st->st_rdev)); + fd =3D open(sysfspath, O_RDONLY); + if (fd =3D=3D -1) { + ret =3D -errno; + goto out; + } + do { + ret =3D read(fd, buf, sizeof(buf)); + } while (ret =3D=3D -1 && errno =3D=3D EINTR); + if (ret < 0) { + ret =3D -errno; + goto out; + } else if (ret =3D=3D 0) { + ret =3D -EIO; + goto out; + } + buf[ret] =3D 0; + /* The file is ended with '\n', pass 'end' to accept that. */ + ret =3D qemu_strtol(buf, &end, 10, &max_segments); + if (ret =3D=3D 0 && end && *end =3D=3D '\n') { + ret =3D max_segments; + } + +out: + g_free(sysfspath); + return ret; +#else + return -ENOTSUP; +#endif +} + static void raw_refresh_limits(BlockDriverState *bs, Error **errp) { BDRVRawState *s =3D bs->opaque; @@ -679,6 +721,11 @@ static void raw_refresh_limits(BlockDriverState *bs, E= rror **errp) if (ret > 0 && ret <=3D BDRV_REQUEST_MAX_BYTES) { bs->bl.max_transfer =3D pow2floor(ret); } + ret =3D hdev_get_max_segments(&st); + if (ret > 0) { + bs->bl.max_transfer =3D MIN(bs->bl.max_transfer, + ret * getpagesize()); + } } } =20 --=20 1.8.3.1 From nobody Thu Nov 6 14:05:17 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489417683311252.4186929340284; Mon, 13 Mar 2017 08:08:03 -0700 (PDT) Received: from localhost ([::1]:52565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRZj-00073c-Lq for importer@patchew.org; Mon, 13 Mar 2017 11:07:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRNk-0005pH-PH for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnRNg-0002vz-W4 for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50952) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnRNY-0002qN-Gd; Mon, 13 Mar 2017 10:55:20 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8E99ED1FE0; Mon, 13 Mar 2017 14:55:20 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-150.ams2.redhat.com [10.36.117.150]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2DEtEUV009408; Mon, 13 Mar 2017 10:55:19 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 13 Mar 2017 15:54:59 +0100 Message-Id: <1489416908-3771-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1489416908-3771-1-git-send-email-kwolf@redhat.com> References: <1489416908-3771-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 13 Mar 2017 14:55:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/12] block: Drop unmaintained 'archipelago' driver X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake The driver has failed to build since commit da34e65, in qemu 2.6, due to a missing include of qapi/error.h for error_setg(). Since no one has complained in three releases, it is easier to remove the dead code than to keep it around, especially since it is not being built by default and therefore prone to bitrot. Signed-off-by: Eric Blake Reviewed-by: Max Reitz Reviewed-by: Fam Zheng Signed-off-by: Kevin Wolf --- MAINTAINERS | 8 - block/Makefile.objs | 2 - block/archipelago.c | 1079 ----------------------------------= ---- configure | 43 -- qapi/block-core.json | 33 +- tests/qemu-iotests/025 | 2 +- tests/qemu-iotests/common | 6 - tests/qemu-iotests/common.filter | 4 +- tests/qemu-iotests/common.rc | 8 - 9 files changed, 4 insertions(+), 1181 deletions(-) delete mode 100644 block/archipelago.c diff --git a/MAINTAINERS b/MAINTAINERS index e3edd04..bf1aafb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1674,14 +1674,6 @@ S: Supported F: block/ssh.c T: git git://github.com/codyprime/qemu-kvm-jtc.git block =20 -ARCHIPELAGO -M: Chrysostomos Nanakos -M: Jeff Cody -L: qemu-block@nongnu.org -S: Maintained -F: block/archipelago.c -T: git git://github.com/codyprime/qemu-kvm-jtc.git block - CURL M: Jeff Cody L: qemu-block@nongnu.org diff --git a/block/Makefile.objs b/block/Makefile.objs index c6bd14e..de96f8ee 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -19,7 +19,6 @@ block-obj-$(CONFIG_LIBNFS) +=3D nfs.o block-obj-$(CONFIG_CURL) +=3D curl.o block-obj-$(CONFIG_RBD) +=3D rbd.o block-obj-$(CONFIG_GLUSTERFS) +=3D gluster.o -block-obj-$(CONFIG_ARCHIPELAGO) +=3D archipelago.o block-obj-$(CONFIG_LIBSSH2) +=3D ssh.o block-obj-y +=3D accounting.o dirty-bitmap.o block-obj-y +=3D write-threshold.o @@ -41,7 +40,6 @@ gluster.o-cflags :=3D $(GLUSTERFS_CFLAGS) gluster.o-libs :=3D $(GLUSTERFS_LIBS) ssh.o-cflags :=3D $(LIBSSH2_CFLAGS) ssh.o-libs :=3D $(LIBSSH2_LIBS) -archipelago.o-libs :=3D $(ARCHIPELAGO_LIBS) block-obj-$(if $(CONFIG_BZIP2),m,n) +=3D dmg-bz2.o dmg-bz2.o-libs :=3D $(BZIP2_LIBS) qcow.o-libs :=3D -lz diff --git a/block/archipelago.c b/block/archipelago.c deleted file mode 100644 index 2449cfc..0000000 --- a/block/archipelago.c +++ /dev/null @@ -1,1079 +0,0 @@ -/* - * QEMU Block driver for Archipelago - * - * Copyright (C) 2014 Chrysostomos Nanakos - * - * This work is licensed under the terms of the GNU GPL, version 2 or late= r. - * See the COPYING file in the top-level directory. - * - */ - -/* - * VM Image on Archipelago volume is specified like this: - * - * file.driver=3Darchipelago,file.volume=3D - * [,file.mport=3D[,file.vport=3D] - * [,file.segment=3D]] - * - * or - * - * file=3Darchipelago:[/mport=3D[:vport=3D][: - * segment=3D]] - * - * 'archipelago' is the protocol. - * - * 'mport' is the port number on which mapperd is listening. This is optio= nal - * and if not specified, QEMU will make Archipelago to use the default por= t. - * - * 'vport' is the port number on which vlmcd is listening. This is optional - * and if not specified, QEMU will make Archipelago to use the default por= t. - * - * 'segment' is the name of the shared memory segment Archipelago stack - * is using. This is optional and if not specified, QEMU will make Archipe= lago - * to use the default value, 'archipelago'. - * - * Examples: - * - * file.driver=3Darchipelago,file.volume=3Dmy_vm_volume - * file.driver=3Darchipelago,file.volume=3Dmy_vm_volume,file.mport=3D123 - * file.driver=3Darchipelago,file.volume=3Dmy_vm_volume,file.mport=3D123, - * file.vport=3D1234 - * file.driver=3Darchipelago,file.volume=3Dmy_vm_volume,file.mport=3D123, - * file.vport=3D1234,file.segment=3Dmy_segment - * - * or - * - * file=3Darchipelago:my_vm_volume - * file=3Darchipelago:my_vm_volume/mport=3D123 - * file=3Darchipelago:my_vm_volume/mport=3D123:vport=3D1234 - * file=3Darchipelago:my_vm_volume/mport=3D123:vport=3D1234:segment=3Dmy_s= egment - * - */ - -#include "qemu/osdep.h" -#include "qemu/cutils.h" -#include "block/block_int.h" -#include "qemu/error-report.h" -#include "qemu/thread.h" -#include "qapi/qmp/qint.h" -#include "qapi/qmp/qstring.h" -#include "qapi/qmp/qjson.h" -#include "qemu/atomic.h" - -#include -#include - -#define MAX_REQUEST_SIZE 524288 - -#define ARCHIPELAGO_OPT_VOLUME "volume" -#define ARCHIPELAGO_OPT_SEGMENT "segment" -#define ARCHIPELAGO_OPT_MPORT "mport" -#define ARCHIPELAGO_OPT_VPORT "vport" -#define ARCHIPELAGO_DFL_MPORT 1001 -#define ARCHIPELAGO_DFL_VPORT 501 - -#define archipelagolog(fmt, ...) \ - do { \ - fprintf(stderr, "archipelago\t%-24s: " fmt, __func__, ##__VA_ARGS_= _); \ - } while (0) - -typedef enum { - ARCHIP_OP_READ, - ARCHIP_OP_WRITE, - ARCHIP_OP_FLUSH, - ARCHIP_OP_VOLINFO, - ARCHIP_OP_TRUNCATE, -} ARCHIPCmd; - -typedef struct ArchipelagoAIOCB { - BlockAIOCB common; - struct BDRVArchipelagoState *s; - QEMUIOVector *qiov; - ARCHIPCmd cmd; - int status; - int64_t size; - int64_t ret; -} ArchipelagoAIOCB; - -typedef struct BDRVArchipelagoState { - ArchipelagoAIOCB *event_acb; - char *volname; - char *segment_name; - uint64_t size; - /* Archipelago specific */ - struct xseg *xseg; - struct xseg_port *port; - xport srcport; - xport sport; - xport mportno; - xport vportno; - QemuMutex archip_mutex; - QemuCond archip_cond; - bool is_signaled; - /* Request handler specific */ - QemuThread request_th; - QemuCond request_cond; - QemuMutex request_mutex; - bool th_is_signaled; - bool stopping; -} BDRVArchipelagoState; - -typedef struct ArchipelagoSegmentedRequest { - size_t count; - size_t total; - int ref; - int failed; -} ArchipelagoSegmentedRequest; - -typedef struct AIORequestData { - const char *volname; - off_t offset; - size_t size; - uint64_t bufidx; - int ret; - int op; - ArchipelagoAIOCB *aio_cb; - ArchipelagoSegmentedRequest *segreq; -} AIORequestData; - -static void qemu_archipelago_complete_aio(void *opaque); - -static void init_local_signal(struct xseg *xseg, xport sport, xport srcpor= t) -{ - if (xseg && (sport !=3D srcport)) { - xseg_init_local_signal(xseg, srcport); - sport =3D srcport; - } -} - -static void archipelago_finish_aiocb(AIORequestData *reqdata) -{ - if (reqdata->aio_cb->ret !=3D reqdata->segreq->total) { - reqdata->aio_cb->ret =3D -EIO; - } else if (reqdata->aio_cb->ret =3D=3D reqdata->segreq->total) { - reqdata->aio_cb->ret =3D 0; - } - aio_bh_schedule_oneshot( - bdrv_get_aio_context(reqdata->aio_cb->common.bs), - qemu_archipelago_complete_aio, reqdata - ); -} - -static int wait_reply(struct xseg *xseg, xport srcport, struct xseg_port *= port, - struct xseg_request *expected_req) -{ - struct xseg_request *req; - xseg_prepare_wait(xseg, srcport); - void *psd =3D xseg_get_signal_desc(xseg, port); - while (1) { - req =3D xseg_receive(xseg, srcport, X_NONBLOCK); - if (req) { - if (req !=3D expected_req) { - archipelagolog("Unknown received request\n"); - xseg_put_request(xseg, req, srcport); - } else if (!(req->state & XS_SERVED)) { - return -1; - } else { - break; - } - } - xseg_wait_signal(xseg, psd, 100000UL); - } - xseg_cancel_wait(xseg, srcport); - return 0; -} - -static void xseg_request_handler(void *state) -{ - BDRVArchipelagoState *s =3D (BDRVArchipelagoState *) state; - void *psd =3D xseg_get_signal_desc(s->xseg, s->port); - qemu_mutex_lock(&s->request_mutex); - - while (!s->stopping) { - struct xseg_request *req; - void *data; - xseg_prepare_wait(s->xseg, s->srcport); - req =3D xseg_receive(s->xseg, s->srcport, X_NONBLOCK); - if (req) { - AIORequestData *reqdata; - ArchipelagoSegmentedRequest *segreq; - xseg_get_req_data(s->xseg, req, (void **)&reqdata); - - switch (reqdata->op) { - case ARCHIP_OP_READ: - data =3D xseg_get_data(s->xseg, req); - segreq =3D reqdata->segreq; - segreq->count +=3D req->serviced; - - qemu_iovec_from_buf(reqdata->aio_cb->qiov, reqdata->bufidx, - data, - req->serviced); - - xseg_put_request(s->xseg, req, s->srcport); - - if (atomic_fetch_dec(&segreq->ref) =3D=3D 1) { - if (!segreq->failed) { - reqdata->aio_cb->ret =3D segreq->count; - archipelago_finish_aiocb(reqdata); - g_free(segreq); - } else { - g_free(segreq); - g_free(reqdata); - } - } else { - g_free(reqdata); - } - break; - case ARCHIP_OP_WRITE: - case ARCHIP_OP_FLUSH: - segreq =3D reqdata->segreq; - segreq->count +=3D req->serviced; - xseg_put_request(s->xseg, req, s->srcport); - - if (atomic_fetch_dec(&segreq->ref) =3D=3D 1) { - if (!segreq->failed) { - reqdata->aio_cb->ret =3D segreq->count; - archipelago_finish_aiocb(reqdata); - g_free(segreq); - } else { - g_free(segreq); - g_free(reqdata); - } - } else { - g_free(reqdata); - } - break; - case ARCHIP_OP_VOLINFO: - case ARCHIP_OP_TRUNCATE: - s->is_signaled =3D true; - qemu_cond_signal(&s->archip_cond); - break; - } - } else { - xseg_wait_signal(s->xseg, psd, 100000UL); - } - xseg_cancel_wait(s->xseg, s->srcport); - } - - s->th_is_signaled =3D true; - qemu_cond_signal(&s->request_cond); - qemu_mutex_unlock(&s->request_mutex); - qemu_thread_exit(NULL); -} - -static int qemu_archipelago_xseg_init(BDRVArchipelagoState *s) -{ - if (xseg_initialize()) { - archipelagolog("Cannot initialize XSEG\n"); - goto err_exit; - } - - s->xseg =3D xseg_join("posix", s->segment_name, - "posixfd", NULL); - if (!s->xseg) { - archipelagolog("Cannot join XSEG shared memory segment\n"); - goto err_exit; - } - s->port =3D xseg_bind_dynport(s->xseg); - s->srcport =3D s->port->portno; - init_local_signal(s->xseg, s->sport, s->srcport); - return 0; - -err_exit: - return -1; -} - -static int qemu_archipelago_init(BDRVArchipelagoState *s) -{ - int ret; - - ret =3D qemu_archipelago_xseg_init(s); - if (ret < 0) { - error_report("Cannot initialize XSEG. Aborting..."); - goto err_exit; - } - - qemu_cond_init(&s->archip_cond); - qemu_mutex_init(&s->archip_mutex); - qemu_cond_init(&s->request_cond); - qemu_mutex_init(&s->request_mutex); - s->th_is_signaled =3D false; - qemu_thread_create(&s->request_th, "xseg_io_th", - (void *) xseg_request_handler, - (void *) s, QEMU_THREAD_JOINABLE); - -err_exit: - return ret; -} - -static void qemu_archipelago_complete_aio(void *opaque) -{ - AIORequestData *reqdata =3D (AIORequestData *) opaque; - ArchipelagoAIOCB *aio_cb =3D (ArchipelagoAIOCB *) reqdata->aio_cb; - - aio_cb->common.cb(aio_cb->common.opaque, aio_cb->ret); - aio_cb->status =3D 0; - - qemu_aio_unref(aio_cb); - g_free(reqdata); -} - -static void xseg_find_port(char *pstr, const char *needle, xport *aport) -{ - const char *a; - char *endptr =3D NULL; - unsigned long port; - if (strstart(pstr, needle, &a)) { - if (strlen(a) > 0) { - port =3D strtoul(a, &endptr, 10); - if (strlen(endptr)) { - *aport =3D -2; - return; - } - *aport =3D (xport) port; - } - } -} - -static void xseg_find_segment(char *pstr, const char *needle, - char **segment_name) -{ - const char *a; - if (strstart(pstr, needle, &a)) { - if (strlen(a) > 0) { - *segment_name =3D g_strdup(a); - } - } -} - -static void parse_filename_opts(const char *filename, Error **errp, - char **volume, char **segment_name, - xport *mport, xport *vport) -{ - const char *start; - char *tokens[4], *ds; - int idx; - xport lmport =3D NoPort, lvport =3D NoPort; - - strstart(filename, "archipelago:", &start); - - ds =3D g_strdup(start); - tokens[0] =3D strtok(ds, "/"); - tokens[1] =3D strtok(NULL, ":"); - tokens[2] =3D strtok(NULL, ":"); - tokens[3] =3D strtok(NULL, "\0"); - - if (!strlen(tokens[0])) { - error_setg(errp, "volume name must be specified first"); - g_free(ds); - return; - } - - for (idx =3D 1; idx < 4; idx++) { - if (tokens[idx] !=3D NULL) { - if (strstart(tokens[idx], "mport=3D", NULL)) { - xseg_find_port(tokens[idx], "mport=3D", &lmport); - } - if (strstart(tokens[idx], "vport=3D", NULL)) { - xseg_find_port(tokens[idx], "vport=3D", &lvport); - } - if (strstart(tokens[idx], "segment=3D", NULL)) { - xseg_find_segment(tokens[idx], "segment=3D", segment_name); - } - } - } - - if ((lmport =3D=3D -2) || (lvport =3D=3D -2)) { - error_setg(errp, "mport and/or vport must be set"); - g_free(ds); - return; - } - *volume =3D g_strdup(tokens[0]); - *mport =3D lmport; - *vport =3D lvport; - g_free(ds); -} - -static void archipelago_parse_filename(const char *filename, QDict *option= s, - Error **errp) -{ - const char *start; - char *volume =3D NULL, *segment_name =3D NULL; - xport mport =3D NoPort, vport =3D NoPort; - - if (qdict_haskey(options, ARCHIPELAGO_OPT_VOLUME) - || qdict_haskey(options, ARCHIPELAGO_OPT_SEGMENT) - || qdict_haskey(options, ARCHIPELAGO_OPT_MPORT) - || qdict_haskey(options, ARCHIPELAGO_OPT_VPORT)) { - error_setg(errp, "volume/mport/vport/segment and a file name may n= ot" - " be specified at the same time"); - return; - } - - if (!strstart(filename, "archipelago:", &start)) { - error_setg(errp, "File name must start with 'archipelago:'"); - return; - } - - if (!strlen(start) || strstart(start, "/", NULL)) { - error_setg(errp, "volume name must be specified"); - return; - } - - parse_filename_opts(filename, errp, &volume, &segment_name, &mport, &v= port); - - if (volume) { - qdict_put(options, ARCHIPELAGO_OPT_VOLUME, qstring_from_str(volume= )); - g_free(volume); - } - if (segment_name) { - qdict_put(options, ARCHIPELAGO_OPT_SEGMENT, - qstring_from_str(segment_name)); - g_free(segment_name); - } - if (mport !=3D NoPort) { - qdict_put(options, ARCHIPELAGO_OPT_MPORT, qint_from_int(mport)); - } - if (vport !=3D NoPort) { - qdict_put(options, ARCHIPELAGO_OPT_VPORT, qint_from_int(vport)); - } -} - -static QemuOptsList archipelago_runtime_opts =3D { - .name =3D "archipelago", - .head =3D QTAILQ_HEAD_INITIALIZER(archipelago_runtime_opts.head), - .desc =3D { - { - .name =3D ARCHIPELAGO_OPT_VOLUME, - .type =3D QEMU_OPT_STRING, - .help =3D "Name of the volume image", - }, - { - .name =3D ARCHIPELAGO_OPT_SEGMENT, - .type =3D QEMU_OPT_STRING, - .help =3D "Name of the Archipelago shared memory segment", - }, - { - .name =3D ARCHIPELAGO_OPT_MPORT, - .type =3D QEMU_OPT_NUMBER, - .help =3D "Archipelago mapperd port number" - }, - { - .name =3D ARCHIPELAGO_OPT_VPORT, - .type =3D QEMU_OPT_NUMBER, - .help =3D "Archipelago vlmcd port number" - - }, - { /* end of list */ } - }, -}; - -static int qemu_archipelago_open(BlockDriverState *bs, - QDict *options, - int bdrv_flags, - Error **errp) -{ - int ret =3D 0; - const char *volume, *segment_name; - QemuOpts *opts; - Error *local_err =3D NULL; - BDRVArchipelagoState *s =3D bs->opaque; - - opts =3D qemu_opts_create(&archipelago_runtime_opts, NULL, 0, &error_a= bort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); - ret =3D -EINVAL; - goto err_exit; - } - - s->mportno =3D qemu_opt_get_number(opts, ARCHIPELAGO_OPT_MPORT, - ARCHIPELAGO_DFL_MPORT); - s->vportno =3D qemu_opt_get_number(opts, ARCHIPELAGO_OPT_VPORT, - ARCHIPELAGO_DFL_VPORT); - - segment_name =3D qemu_opt_get(opts, ARCHIPELAGO_OPT_SEGMENT); - if (segment_name =3D=3D NULL) { - s->segment_name =3D g_strdup("archipelago"); - } else { - s->segment_name =3D g_strdup(segment_name); - } - - volume =3D qemu_opt_get(opts, ARCHIPELAGO_OPT_VOLUME); - if (volume =3D=3D NULL) { - error_setg(errp, "archipelago block driver requires the 'volume'" - " option"); - ret =3D -EINVAL; - goto err_exit; - } - s->volname =3D g_strdup(volume); - - /* Initialize XSEG, join shared memory segment */ - ret =3D qemu_archipelago_init(s); - if (ret < 0) { - error_setg(errp, "cannot initialize XSEG and join shared " - "memory segment"); - goto err_exit; - } - - qemu_opts_del(opts); - return 0; - -err_exit: - g_free(s->volname); - g_free(s->segment_name); - qemu_opts_del(opts); - return ret; -} - -static void qemu_archipelago_close(BlockDriverState *bs) -{ - int r, targetlen; - char *target; - struct xseg_request *req; - BDRVArchipelagoState *s =3D bs->opaque; - - s->stopping =3D true; - - qemu_mutex_lock(&s->request_mutex); - while (!s->th_is_signaled) { - qemu_cond_wait(&s->request_cond, - &s->request_mutex); - } - qemu_mutex_unlock(&s->request_mutex); - qemu_thread_join(&s->request_th); - qemu_cond_destroy(&s->request_cond); - qemu_mutex_destroy(&s->request_mutex); - - qemu_cond_destroy(&s->archip_cond); - qemu_mutex_destroy(&s->archip_mutex); - - targetlen =3D strlen(s->volname); - req =3D xseg_get_request(s->xseg, s->srcport, s->vportno, X_ALLOC); - if (!req) { - archipelagolog("Cannot get XSEG request\n"); - goto err_exit; - } - r =3D xseg_prep_request(s->xseg, req, targetlen, 0); - if (r < 0) { - xseg_put_request(s->xseg, req, s->srcport); - archipelagolog("Cannot prepare XSEG close request\n"); - goto err_exit; - } - - target =3D xseg_get_target(s->xseg, req); - memcpy(target, s->volname, targetlen); - req->size =3D req->datalen; - req->offset =3D 0; - req->op =3D X_CLOSE; - - xport p =3D xseg_submit(s->xseg, req, s->srcport, X_ALLOC); - if (p =3D=3D NoPort) { - xseg_put_request(s->xseg, req, s->srcport); - archipelagolog("Cannot submit XSEG close request\n"); - goto err_exit; - } - - xseg_signal(s->xseg, p); - wait_reply(s->xseg, s->srcport, s->port, req); - - xseg_put_request(s->xseg, req, s->srcport); - -err_exit: - g_free(s->volname); - g_free(s->segment_name); - xseg_quit_local_signal(s->xseg, s->srcport); - xseg_leave_dynport(s->xseg, s->port); - xseg_leave(s->xseg); -} - -static int qemu_archipelago_create_volume(Error **errp, const char *volnam= e, - char *segment_name, - uint64_t size, xport mportno, - xport vportno) -{ - int ret, targetlen; - struct xseg *xseg =3D NULL; - struct xseg_request *req; - struct xseg_request_clone *xclone; - struct xseg_port *port; - xport srcport =3D NoPort, sport =3D NoPort; - char *target; - - /* Try default values if none has been set */ - if (mportno =3D=3D (xport) -1) { - mportno =3D ARCHIPELAGO_DFL_MPORT; - } - - if (vportno =3D=3D (xport) -1) { - vportno =3D ARCHIPELAGO_DFL_VPORT; - } - - if (xseg_initialize()) { - error_setg(errp, "Cannot initialize XSEG"); - return -1; - } - - xseg =3D xseg_join("posix", segment_name, - "posixfd", NULL); - - if (!xseg) { - error_setg(errp, "Cannot join XSEG shared memory segment"); - return -1; - } - - port =3D xseg_bind_dynport(xseg); - srcport =3D port->portno; - init_local_signal(xseg, sport, srcport); - - req =3D xseg_get_request(xseg, srcport, mportno, X_ALLOC); - if (!req) { - error_setg(errp, "Cannot get XSEG request"); - return -1; - } - - targetlen =3D strlen(volname); - ret =3D xseg_prep_request(xseg, req, targetlen, - sizeof(struct xseg_request_clone)); - if (ret < 0) { - error_setg(errp, "Cannot prepare XSEG request"); - goto err_exit; - } - - target =3D xseg_get_target(xseg, req); - if (!target) { - error_setg(errp, "Cannot get XSEG target."); - goto err_exit; - } - memcpy(target, volname, targetlen); - xclone =3D (struct xseg_request_clone *) xseg_get_data(xseg, req); - memset(xclone->target, 0 , XSEG_MAX_TARGETLEN); - xclone->targetlen =3D 0; - xclone->size =3D size; - req->offset =3D 0; - req->size =3D req->datalen; - req->op =3D X_CLONE; - - xport p =3D xseg_submit(xseg, req, srcport, X_ALLOC); - if (p =3D=3D NoPort) { - error_setg(errp, "Could not submit XSEG request"); - goto err_exit; - } - xseg_signal(xseg, p); - - ret =3D wait_reply(xseg, srcport, port, req); - if (ret < 0) { - error_setg(errp, "wait_reply() error."); - } - - xseg_put_request(xseg, req, srcport); - xseg_quit_local_signal(xseg, srcport); - xseg_leave_dynport(xseg, port); - xseg_leave(xseg); - return ret; - -err_exit: - xseg_put_request(xseg, req, srcport); - xseg_quit_local_signal(xseg, srcport); - xseg_leave_dynport(xseg, port); - xseg_leave(xseg); - return -1; -} - -static int qemu_archipelago_create(const char *filename, - QemuOpts *options, - Error **errp) -{ - int ret =3D 0; - uint64_t total_size =3D 0; - char *volname =3D NULL, *segment_name =3D NULL; - const char *start; - xport mport =3D NoPort, vport =3D NoPort; - - if (!strstart(filename, "archipelago:", &start)) { - error_setg(errp, "File name must start with 'archipelago:'"); - return -1; - } - - if (!strlen(start) || strstart(start, "/", NULL)) { - error_setg(errp, "volume name must be specified"); - return -1; - } - - parse_filename_opts(filename, errp, &volname, &segment_name, &mport, - &vport); - total_size =3D ROUND_UP(qemu_opt_get_size_del(options, BLOCK_OPT_SIZE,= 0), - BDRV_SECTOR_SIZE); - - if (segment_name =3D=3D NULL) { - segment_name =3D g_strdup("archipelago"); - } - - /* Create an Archipelago volume */ - ret =3D qemu_archipelago_create_volume(errp, volname, segment_name, - total_size, mport, - vport); - - g_free(volname); - g_free(segment_name); - return ret; -} - -static const AIOCBInfo archipelago_aiocb_info =3D { - .aiocb_size =3D sizeof(ArchipelagoAIOCB), -}; - -static int archipelago_submit_request(BDRVArchipelagoState *s, - uint64_t bufidx, - size_t count, - off_t offset, - ArchipelagoAIOCB *aio_cb, - ArchipelagoSegmentedRequest *segre= q, - int op) -{ - int ret, targetlen; - char *target; - void *data =3D NULL; - struct xseg_request *req; - AIORequestData *reqdata =3D g_new(AIORequestData, 1); - - targetlen =3D strlen(s->volname); - req =3D xseg_get_request(s->xseg, s->srcport, s->vportno, X_ALLOC); - if (!req) { - archipelagolog("Cannot get XSEG request\n"); - goto err_exit2; - } - ret =3D xseg_prep_request(s->xseg, req, targetlen, count); - if (ret < 0) { - archipelagolog("Cannot prepare XSEG request\n"); - goto err_exit; - } - target =3D xseg_get_target(s->xseg, req); - if (!target) { - archipelagolog("Cannot get XSEG target\n"); - goto err_exit; - } - memcpy(target, s->volname, targetlen); - req->size =3D count; - req->offset =3D offset; - - switch (op) { - case ARCHIP_OP_READ: - req->op =3D X_READ; - break; - case ARCHIP_OP_WRITE: - req->op =3D X_WRITE; - break; - case ARCHIP_OP_FLUSH: - req->op =3D X_FLUSH; - break; - } - reqdata->volname =3D s->volname; - reqdata->offset =3D offset; - reqdata->size =3D count; - reqdata->bufidx =3D bufidx; - reqdata->aio_cb =3D aio_cb; - reqdata->segreq =3D segreq; - reqdata->op =3D op; - - xseg_set_req_data(s->xseg, req, reqdata); - if (op =3D=3D ARCHIP_OP_WRITE) { - data =3D xseg_get_data(s->xseg, req); - if (!data) { - archipelagolog("Cannot get XSEG data\n"); - goto err_exit; - } - qemu_iovec_to_buf(aio_cb->qiov, bufidx, data, count); - } - - xport p =3D xseg_submit(s->xseg, req, s->srcport, X_ALLOC); - if (p =3D=3D NoPort) { - archipelagolog("Could not submit XSEG request\n"); - goto err_exit; - } - xseg_signal(s->xseg, p); - return 0; - -err_exit: - g_free(reqdata); - xseg_put_request(s->xseg, req, s->srcport); - return -EIO; -err_exit2: - g_free(reqdata); - return -EIO; -} - -static int archipelago_aio_segmented_rw(BDRVArchipelagoState *s, - size_t count, - off_t offset, - ArchipelagoAIOCB *aio_cb, - int op) -{ - int ret, segments_nr; - size_t pos =3D 0; - ArchipelagoSegmentedRequest *segreq; - - segreq =3D g_new0(ArchipelagoSegmentedRequest, 1); - - if (op =3D=3D ARCHIP_OP_FLUSH) { - segments_nr =3D 1; - } else { - segments_nr =3D (int)(count / MAX_REQUEST_SIZE) + \ - ((count % MAX_REQUEST_SIZE) ? 1 : 0); - } - segreq->total =3D count; - atomic_mb_set(&segreq->ref, segments_nr); - - while (segments_nr > 1) { - ret =3D archipelago_submit_request(s, pos, - MAX_REQUEST_SIZE, - offset + pos, - aio_cb, segreq, op); - - if (ret < 0) { - goto err_exit; - } - count -=3D MAX_REQUEST_SIZE; - pos +=3D MAX_REQUEST_SIZE; - segments_nr--; - } - ret =3D archipelago_submit_request(s, pos, count, offset + pos, - aio_cb, segreq, op); - - if (ret < 0) { - goto err_exit; - } - return 0; - -err_exit: - segreq->failed =3D 1; - if (atomic_fetch_sub(&segreq->ref, segments_nr) =3D=3D segments_nr) { - g_free(segreq); - } - return ret; -} - -static BlockAIOCB *qemu_archipelago_aio_rw(BlockDriverState *bs, - int64_t sector_num, - QEMUIOVector *qiov, - int nb_sectors, - BlockCompletionFunc *cb, - void *opaque, - int op) -{ - ArchipelagoAIOCB *aio_cb; - BDRVArchipelagoState *s =3D bs->opaque; - int64_t size, off; - int ret; - - aio_cb =3D qemu_aio_get(&archipelago_aiocb_info, bs, cb, opaque); - aio_cb->cmd =3D op; - aio_cb->qiov =3D qiov; - - aio_cb->ret =3D 0; - aio_cb->s =3D s; - aio_cb->status =3D -EINPROGRESS; - - off =3D sector_num * BDRV_SECTOR_SIZE; - size =3D nb_sectors * BDRV_SECTOR_SIZE; - aio_cb->size =3D size; - - ret =3D archipelago_aio_segmented_rw(s, size, off, - aio_cb, op); - if (ret < 0) { - goto err_exit; - } - return &aio_cb->common; - -err_exit: - error_report("qemu_archipelago_aio_rw(): I/O Error"); - qemu_aio_unref(aio_cb); - return NULL; -} - -static BlockAIOCB *qemu_archipelago_aio_readv(BlockDriverState *bs, - int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, - BlockCompletionFunc *cb, void *opaque) -{ - return qemu_archipelago_aio_rw(bs, sector_num, qiov, nb_sectors, cb, - opaque, ARCHIP_OP_READ); -} - -static BlockAIOCB *qemu_archipelago_aio_writev(BlockDriverState *bs, - int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, - BlockCompletionFunc *cb, void *opaque) -{ - return qemu_archipelago_aio_rw(bs, sector_num, qiov, nb_sectors, cb, - opaque, ARCHIP_OP_WRITE); -} - -static int64_t archipelago_volume_info(BDRVArchipelagoState *s) -{ - uint64_t size; - int ret, targetlen; - struct xseg_request *req; - struct xseg_reply_info *xinfo; - AIORequestData *reqdata =3D g_new(AIORequestData, 1); - - const char *volname =3D s->volname; - targetlen =3D strlen(volname); - req =3D xseg_get_request(s->xseg, s->srcport, s->mportno, X_ALLOC); - if (!req) { - archipelagolog("Cannot get XSEG request\n"); - goto err_exit2; - } - ret =3D xseg_prep_request(s->xseg, req, targetlen, - sizeof(struct xseg_reply_info)); - if (ret < 0) { - archipelagolog("Cannot prepare XSEG request\n"); - goto err_exit; - } - char *target =3D xseg_get_target(s->xseg, req); - if (!target) { - archipelagolog("Cannot get XSEG target\n"); - goto err_exit; - } - memcpy(target, volname, targetlen); - req->size =3D req->datalen; - req->offset =3D 0; - req->op =3D X_INFO; - - reqdata->op =3D ARCHIP_OP_VOLINFO; - reqdata->volname =3D volname; - xseg_set_req_data(s->xseg, req, reqdata); - - xport p =3D xseg_submit(s->xseg, req, s->srcport, X_ALLOC); - if (p =3D=3D NoPort) { - archipelagolog("Cannot submit XSEG request\n"); - goto err_exit; - } - xseg_signal(s->xseg, p); - qemu_mutex_lock(&s->archip_mutex); - while (!s->is_signaled) { - qemu_cond_wait(&s->archip_cond, &s->archip_mutex); - } - s->is_signaled =3D false; - qemu_mutex_unlock(&s->archip_mutex); - - xinfo =3D (struct xseg_reply_info *) xseg_get_data(s->xseg, req); - size =3D xinfo->size; - xseg_put_request(s->xseg, req, s->srcport); - g_free(reqdata); - s->size =3D size; - return size; - -err_exit: - xseg_put_request(s->xseg, req, s->srcport); -err_exit2: - g_free(reqdata); - return -EIO; -} - -static int64_t qemu_archipelago_getlength(BlockDriverState *bs) -{ - BDRVArchipelagoState *s =3D bs->opaque; - - return archipelago_volume_info(s); -} - -static int qemu_archipelago_truncate(BlockDriverState *bs, int64_t offset) -{ - int ret, targetlen; - struct xseg_request *req; - BDRVArchipelagoState *s =3D bs->opaque; - AIORequestData *reqdata =3D g_new(AIORequestData, 1); - - const char *volname =3D s->volname; - targetlen =3D strlen(volname); - req =3D xseg_get_request(s->xseg, s->srcport, s->mportno, X_ALLOC); - if (!req) { - archipelagolog("Cannot get XSEG request\n"); - goto err_exit2; - } - - ret =3D xseg_prep_request(s->xseg, req, targetlen, 0); - if (ret < 0) { - archipelagolog("Cannot prepare XSEG request\n"); - goto err_exit; - } - char *target =3D xseg_get_target(s->xseg, req); - if (!target) { - archipelagolog("Cannot get XSEG target\n"); - goto err_exit; - } - memcpy(target, volname, targetlen); - req->offset =3D offset; - req->op =3D X_TRUNCATE; - - reqdata->op =3D ARCHIP_OP_TRUNCATE; - reqdata->volname =3D volname; - - xseg_set_req_data(s->xseg, req, reqdata); - - xport p =3D xseg_submit(s->xseg, req, s->srcport, X_ALLOC); - if (p =3D=3D NoPort) { - archipelagolog("Cannot submit XSEG request\n"); - goto err_exit; - } - - xseg_signal(s->xseg, p); - qemu_mutex_lock(&s->archip_mutex); - while (!s->is_signaled) { - qemu_cond_wait(&s->archip_cond, &s->archip_mutex); - } - s->is_signaled =3D false; - qemu_mutex_unlock(&s->archip_mutex); - xseg_put_request(s->xseg, req, s->srcport); - g_free(reqdata); - return 0; - -err_exit: - xseg_put_request(s->xseg, req, s->srcport); -err_exit2: - g_free(reqdata); - return -EIO; -} - -static QemuOptsList qemu_archipelago_create_opts =3D { - .name =3D "archipelago-create-opts", - .head =3D QTAILQ_HEAD_INITIALIZER(qemu_archipelago_create_opts.head), - .desc =3D { - { - .name =3D BLOCK_OPT_SIZE, - .type =3D QEMU_OPT_SIZE, - .help =3D "Virtual disk size" - }, - { /* end of list */ } - } -}; - -static BlockAIOCB *qemu_archipelago_aio_flush(BlockDriverState *bs, - BlockCompletionFunc *cb, void *opaque) -{ - return qemu_archipelago_aio_rw(bs, 0, NULL, 0, cb, opaque, - ARCHIP_OP_FLUSH); -} - -static BlockDriver bdrv_archipelago =3D { - .format_name =3D "archipelago", - .protocol_name =3D "archipelago", - .instance_size =3D sizeof(BDRVArchipelagoState), - .bdrv_parse_filename =3D archipelago_parse_filename, - .bdrv_file_open =3D qemu_archipelago_open, - .bdrv_close =3D qemu_archipelago_close, - .bdrv_create =3D qemu_archipelago_create, - .bdrv_getlength =3D qemu_archipelago_getlength, - .bdrv_truncate =3D qemu_archipelago_truncate, - .bdrv_aio_readv =3D qemu_archipelago_aio_readv, - .bdrv_aio_writev =3D qemu_archipelago_aio_writev, - .bdrv_aio_flush =3D qemu_archipelago_aio_flush, - .bdrv_has_zero_init =3D bdrv_has_zero_init_1, - .create_opts =3D &qemu_archipelago_create_opts, -}; - -static void bdrv_archipelago_init(void) -{ - bdrv_register(&bdrv_archipelago); -} - -block_init(bdrv_archipelago_init); diff --git a/configure b/configure index 6c21975..b05c376 100755 --- a/configure +++ b/configure @@ -301,7 +301,6 @@ glusterfs=3D"" glusterfs_xlator_opt=3D"no" glusterfs_discard=3D"no" glusterfs_zerofill=3D"no" -archipelago=3D"no" gtk=3D"" gtkabi=3D"" gtk_gl=3D"no" @@ -1101,10 +1100,6 @@ for opt do ;; --enable-glusterfs) glusterfs=3D"yes" ;; - --disable-archipelago) archipelago=3D"no" - ;; - --enable-archipelago) archipelago=3D"yes" - ;; --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane) echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2 ;; @@ -1396,7 +1391,6 @@ disabled with --disable-FEATURE, default is enabled i= f available: seccomp seccomp support coroutine-pool coroutine freelist (better performance) glusterfs GlusterFS backend - archipelago Archipelago backend tpm TPM support libssh2 ssh block device support numa libnuma support @@ -3466,37 +3460,6 @@ EOF fi fi =20 -########################################## -# archipelago probe -if test "$archipelago" !=3D "no" ; then - cat > $TMPC < -#include -#include -int main(void) { - xseg_initialize(); - return 0; -} -EOF - archipelago_libs=3D-lxseg - if compile_prog "" "$archipelago_libs"; then - archipelago=3D"yes" - libs_tools=3D"$archipelago_libs $libs_tools" - libs_softmmu=3D"$archipelago_libs $libs_softmmu" - - echo "WARNING: Please check the licenses of QEMU and libxseg carefully." - echo "GPLv3 versions of libxseg may not be compatible with QEMU's" - echo "license and therefore prevent redistribution." - echo - echo "To disable Archipelago, use --disable-archipelago" - else - if test "$archipelago" =3D "yes" ; then - feature_not_found "Archipelago backend support" "Install libxseg d= evel" - fi - archipelago=3D"no" - fi -fi - =20 ########################################## # glusterfs probe @@ -5099,7 +5062,6 @@ echo "coroutine backend $coroutine" echo "coroutine pool $coroutine_pool" echo "debug stack usage $debug_stack_usage" echo "GlusterFS support $glusterfs" -echo "Archipelago support $archipelago" echo "gcov $gcov_tool" echo "gcov enabled $gcov" echo "TPM support $tpm" @@ -5640,11 +5602,6 @@ if test "$glusterfs_zerofill" =3D "yes" ; then echo "CONFIG_GLUSTERFS_ZEROFILL=3Dy" >> $config_host_mak fi =20 -if test "$archipelago" =3D "yes" ; then - echo "CONFIG_ARCHIPELAGO=3Dm" >> $config_host_mak - echo "ARCHIPELAGO_LIBS=3D$archipelago_libs" >> $config_host_mak -fi - if test "$libssh2" =3D "yes" ; then echo "CONFIG_LIBSSH2=3Dm" >> $config_host_mak echo "LIBSSH2_CFLAGS=3D$libssh2_cflags" >> $config_host_mak diff --git a/qapi/block-core.json b/qapi/block-core.json index 9bb7f4a..786b39e 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -251,6 +251,7 @@ # 2.5: 'host_floppy' dropped # 2.6: 'luks' added # 2.8: 'replication' added, 'tftp' dropped +# 2.9: 'archipelago' dropped # # @backing_file: #optional the name of the backing file (for copy-on-write) # @@ -2129,7 +2130,7 @@ # Since: 2.0 ## { 'enum': 'BlockdevDriver', - 'data': [ 'archipelago', 'blkdebug', 'blkverify', 'bochs', 'cloop', + 'data': [ 'blkdebug', 'blkverify', 'bochs', 'cloop', 'dmg', 'file', 'ftp', 'ftps', 'gluster', 'host_cdrom', 'host_device', 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'parallels', 'qcow', 'qcow2', 'qed', @@ -2343,35 +2344,6 @@ =20 =20 ## -# @BlockdevOptionsArchipelago: -# -# Driver specific block device options for Archipelago. -# -# @volume: Name of the Archipelago volume image -# -# @mport: #optional The port number on which mapperd is -# listening. This is optional -# and if not specified, QEMU will make Archipelago -# use the default port (1001). -# -# @vport: #optional The port number on which vlmcd is -# listening. This is optional -# and if not specified, QEMU will make Archipelago -# use the default port (501). -# -# @segment: #optional The name of the shared memory segment -# Archipelago stack is using. This is optional -# and if not specified, QEMU will make Archipelago -# use the default value, 'archipelago'. -# Since: 2.2 -## -{ 'struct': 'BlockdevOptionsArchipelago', - 'data': { 'volume': 'str', - '*mport': 'int', - '*vport': 'int', - '*segment': 'str' } } - -## # @BlockdevOptionsSsh: # # @server: host address @@ -2884,7 +2856,6 @@ '*detect-zeroes': 'BlockdevDetectZeroesOptions' }, 'discriminator': 'driver', 'data': { - 'archipelago':'BlockdevOptionsArchipelago', 'blkdebug': 'BlockdevOptionsBlkdebug', 'blkverify': 'BlockdevOptionsBlkverify', 'bochs': 'BlockdevOptionsGenericFormat', diff --git a/tests/qemu-iotests/025 b/tests/qemu-iotests/025 index c41370f..f5e672e 100755 --- a/tests/qemu-iotests/025 +++ b/tests/qemu-iotests/025 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.pattern =20 _supported_fmt raw qcow2 qed -_supported_proto file sheepdog rbd nfs archipelago +_supported_proto file sheepdog rbd nfs _supported_os Linux =20 echo "=3D=3D=3D Creating image" diff --git a/tests/qemu-iotests/common b/tests/qemu-iotests/common index b6274be..4d5650d 100644 --- a/tests/qemu-iotests/common +++ b/tests/qemu-iotests/common @@ -156,7 +156,6 @@ check options -nbd test nbd -ssh test ssh -nfs test nfs - -archipelago test archipelago -luks test luks -xdiff graphical mode diff -nocache use O_DIRECT on backing file @@ -271,11 +270,6 @@ testlist options xpand=3Dfalse ;; =20 - -archipelago) - IMGPROTO=3Darchipelago - xpand=3Dfalse - ;; - -nocache) CACHEMODE=3D"none" CACHEMODE_IS_DEFAULT=3Dfalse diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.f= ilter index 4befd86..1040013 100644 --- a/tests/qemu-iotests/common.filter +++ b/tests/qemu-iotests/common.filter @@ -112,7 +112,6 @@ _filter_img_create() -e "s# block_size=3D[0-9]\\+##g" \ -e "s# block_state_zero=3D\\(on\\|off\\)##g" \ -e "s# log_size=3D[0-9]\\+##g" \ - -e "s/archipelago:a/TEST_DIR\//g" \ -e "s# refcount_bits=3D[0-9]\\+##g" \ -e "s# key-secret=3D[a-zA-Z0-9]\\+##g" } @@ -136,8 +135,7 @@ _filter_img_info() -e "/lazy_refcounts: \\(on\\|off\\)/d" \ -e "/block_size: [0-9]\\+/d" \ -e "/block_state_zero: \\(on\\|off\\)/d" \ - -e "/log_size: [0-9]\\+/d" \ - -e "s/archipelago:a/TEST_DIR\//g" + -e "/log_size: [0-9]\\+/d" } =20 # filter out offsets and file names from qemu-img map diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index 08065dc..7d4781d 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -70,8 +70,6 @@ if [ "$IMGOPTSSYNTAX" =3D "true" ]; then elif [ "$IMGPROTO" =3D "nfs" ]; then TEST_DIR=3D"$DRIVER,file.driver=3Dnfs,file.filename=3Dnfs://127.0.= 0.1/$TEST_DIR" TEST_IMG=3D$TEST_DIR/t.$IMGFMT - elif [ "$IMGPROTO" =3D "archipelago" ]; then - TEST_IMG=3D"$DRIVER,file.driver=3Darchipelago,file.volume=3D:at.$I= MGFMT" else TEST_IMG=3D"$DRIVER,file.driver=3D$IMGPROTO,file.filename=3D$TEST_= DIR/t.$IMGFMT" fi @@ -87,8 +85,6 @@ else elif [ "$IMGPROTO" =3D "nfs" ]; then TEST_DIR=3D"nfs://127.0.0.1/$TEST_DIR" TEST_IMG=3D$TEST_DIR/t.$IMGFMT - elif [ "$IMGPROTO" =3D "archipelago" ]; then - TEST_IMG=3D"archipelago:at.$IMGFMT" else TEST_IMG=3D$IMGPROTO:$TEST_DIR/t.$IMGFMT fi @@ -215,10 +211,6 @@ _cleanup_test_img() rbd --no-progress rm "$TEST_DIR/t.$IMGFMT" > /dev/null ;; =20 - archipelago) - vlmc remove "at.$IMGFMT" > /dev/null - ;; - sheepdog) collie vdi delete "$TEST_DIR/t.$IMGFMT" ;; --=20 1.8.3.1 From nobody Thu Nov 6 14:05:17 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489416990013788.220064056845; Mon, 13 Mar 2017 07:56:30 -0700 (PDT) Received: from localhost ([::1]:52493 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnROe-0005kK-Ra for importer@patchew.org; Mon, 13 Mar 2017 10:56:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRNd-0005hG-HO for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnRNc-0002tj-NO for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56056) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnRNZ-0002r7-Re; Mon, 13 Mar 2017 10:55:21 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DE0837E9FD; Mon, 13 Mar 2017 14:55:21 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-150.ams2.redhat.com [10.36.117.150]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2DEtEUW009408; Mon, 13 Mar 2017 10:55:20 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 13 Mar 2017 15:55:00 +0100 Message-Id: <1489416908-3771-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1489416908-3771-1-git-send-email-kwolf@redhat.com> References: <1489416908-3771-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 13 Mar 2017 14:55:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/12] backup: React to bdrv_is_allocated() errors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake If bdrv_is_allocated() fails, we should immediately do the backup error action, rather than attempting backup_do_cow() (although that will likely fail too). Signed-off-by: Eric Blake Signed-off-by: Kevin Wolf --- block/backup.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/block/backup.c b/block/backup.c index d3d20db..a4fb288 100644 --- a/block/backup.c +++ b/block/backup.c @@ -468,13 +468,14 @@ static void coroutine_fn backup_run(void *opaque) /* Both FULL and TOP SYNC_MODE's require copying.. */ for (; start < end; start++) { bool error_is_read; + int alloced =3D 0; + if (yield_and_check(job)) { break; } =20 if (job->sync_mode =3D=3D MIRROR_SYNC_MODE_TOP) { int i, n; - int alloced =3D 0; =20 /* Check to see if these blocks are already in the * backing file. */ @@ -492,7 +493,7 @@ static void coroutine_fn backup_run(void *opaque) sectors_per_cluster - i, &n); i +=3D n; =20 - if (alloced =3D=3D 1 || n =3D=3D 0) { + if (alloced || n =3D=3D 0) { break; } } @@ -504,8 +505,13 @@ static void coroutine_fn backup_run(void *opaque) } } /* FULL sync mode we copy the whole drive. */ - ret =3D backup_do_cow(job, start * sectors_per_cluster, - sectors_per_cluster, &error_is_read, false= ); + if (alloced < 0) { + ret =3D alloced; + } else { + ret =3D backup_do_cow(job, start * sectors_per_cluster, + sectors_per_cluster, &error_is_read, + false); + } if (ret < 0) { /* Depending on error action, fail now or retry cluster */ BlockErrorAction action =3D --=20 1.8.3.1 From nobody Thu Nov 6 14:05:17 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489417136460495.64209214121104; Mon, 13 Mar 2017 07:58:56 -0700 (PDT) Received: from localhost ([::1]:52504 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRR1-0007ns-8E for importer@patchew.org; Mon, 13 Mar 2017 10:58:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35152) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRNe-0005iU-HV for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnRNd-0002uR-Mk for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35116) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnRNb-0002ry-3W; Mon, 13 Mar 2017 10:55:23 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 339F581F07; Mon, 13 Mar 2017 14:55:23 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-150.ams2.redhat.com [10.36.117.150]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2DEtEUX009408; Mon, 13 Mar 2017 10:55:22 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 13 Mar 2017 15:55:01 +0100 Message-Id: <1489416908-3771-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1489416908-3771-1-git-send-email-kwolf@redhat.com> References: <1489416908-3771-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 13 Mar 2017 14:55:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 05/12] vvfat: React to bdrv_is_allocated() errors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake If bdrv_is_allocated() fails, we should react to that failure. For 2 of the 3 callers, reporting the error was easy. But in cluster_was_modified() and its lone caller get_cluster_count_for_direntry(), it's rather invasive to update the logic to pass the error back; so there, I went with merely documenting the issue by changing the return type to bool (in all likelihood, treating the cluster as modified will then trigger a read which will also fail, and eventually get to an error - but given the appalling number of abort() calls in this code, I'm not making it any worse). Signed-off-by: Eric Blake Signed-off-by: Kevin Wolf --- block/vvfat.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index aa61c32..af5153d 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1394,7 +1394,13 @@ static int vvfat_read(BlockDriverState *bs, int64_t = sector_num, return -1; if (s->qcow) { int n; - if (bdrv_is_allocated(s->qcow->bs, sector_num, nb_sectors-i, &= n)) { + int ret; + ret =3D bdrv_is_allocated(s->qcow->bs, sector_num, + nb_sectors - i, &n); + if (ret < 0) { + return ret; + } + if (ret) { DLOG(fprintf(stderr, "sectors %d+%d allocated\n", (int)sector_num, n)); if (bdrv_read(s->qcow, sector_num, buf + i * 0x200, n)) { @@ -1668,7 +1674,8 @@ static inline uint32_t modified_fat_get(BDRVVVFATStat= e* s, } } =20 -static inline int cluster_was_modified(BDRVVVFATState* s, uint32_t cluster= _num) +static inline bool cluster_was_modified(BDRVVVFATState *s, + uint32_t cluster_num) { int was_modified =3D 0; int i, dummy; @@ -1683,7 +1690,13 @@ static inline int cluster_was_modified(BDRVVVFATStat= e* s, uint32_t cluster_num) 1, &dummy); } =20 - return was_modified; + /* + * Note that this treats failures to learn allocation status the + * same as if an allocation has occurred. It's as safe as + * anything else, given that a failure to learn allocation status + * will probably result in more failures. + */ + return !!was_modified; } =20 static const char* get_basename(const char* path) @@ -1833,6 +1846,9 @@ static uint32_t get_cluster_count_for_direntry(BDRVVV= FATState* s, int res; =20 res =3D bdrv_is_allocated(s->qcow->bs, offset + i, 1, = &dummy); + if (res < 0) { + return -1; + } if (!res) { res =3D vvfat_read(s->bs, offset, s->cluster_buffe= r, 1); if (res) { --=20 1.8.3.1 From nobody Thu Nov 6 14:05:17 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489417283539623.6160587880573; Mon, 13 Mar 2017 08:01:23 -0700 (PDT) Received: from localhost ([::1]:52524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRTK-0001TG-5k for importer@patchew.org; Mon, 13 Mar 2017 11:01:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRNi-0005mZ-Il for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnRNe-0002uz-Lm for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35272) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnRNc-0002tH-Fj; Mon, 13 Mar 2017 10:55:24 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D3FA64DAD; Mon, 13 Mar 2017 14:55:24 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-150.ams2.redhat.com [10.36.117.150]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2DEtEUY009408; Mon, 13 Mar 2017 10:55:23 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 13 Mar 2017 15:55:02 +0100 Message-Id: <1489416908-3771-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1489416908-3771-1-git-send-email-kwolf@redhat.com> References: <1489416908-3771-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 13 Mar 2017 14:55:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/12] migration: Document handling of bdrv_is_allocated() errors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake Migration is the only code left in the tree that does not react to bdrv_is_allocated() failures. But as there is no useful way to react to the failure, and we are merely skipping unallocated sectors on success, just document that our choice of handling is intended. Signed-off-by: Eric Blake Signed-off-by: Kevin Wolf --- migration/block.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migration/block.c b/migration/block.c index 1941bc2..6741228 100644 --- a/migration/block.c +++ b/migration/block.c @@ -276,6 +276,8 @@ static int mig_save_device_bulk(QEMUFile *f, BlkMigDevS= tate *bmds) if (bmds->shared_base) { qemu_mutex_lock_iothread(); aio_context_acquire(blk_get_aio_context(bb)); + /* Skip unallocated sectors; intentionally treats failure as + * an allocated sector */ while (cur_sector < total_sectors && !bdrv_is_allocated(blk_bs(bb), cur_sector, MAX_IS_ALLOCATED_SEARCH, &nr_sectors)) { --=20 1.8.3.1 From nobody Thu Nov 6 14:05:17 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489417433937298.85594022453756; Mon, 13 Mar 2017 08:03:53 -0700 (PDT) Received: from localhost ([::1]:52543 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRVl-0003VN-OG for importer@patchew.org; Mon, 13 Mar 2017 11:03:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRNj-0005no-K8 for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnRNi-0002we-Ps for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35292) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnRNd-0002uE-Mb; Mon, 13 Mar 2017 10:55:25 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C83D164DAD; Mon, 13 Mar 2017 14:55:25 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-150.ams2.redhat.com [10.36.117.150]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2DEtEUZ009408; Mon, 13 Mar 2017 10:55:24 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 13 Mar 2017 15:55:03 +0100 Message-Id: <1489416908-3771-8-git-send-email-kwolf@redhat.com> In-Reply-To: <1489416908-3771-1-git-send-email-kwolf@redhat.com> References: <1489416908-3771-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 13 Mar 2017 14:55:25 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 07/12] block: Remove check_new_perm from bdrv_replace_child() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" All callers pass false now, so the parameter can go away again. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/block.c b/block.c index b404ef2..dd38e71 100644 --- a/block.c +++ b/block.c @@ -1756,8 +1756,18 @@ static void bdrv_replace_child_noperm(BdrvChild *chi= ld, } } =20 -static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs, - bool check_new_perm) +/* + * Updates @child to change its reference to point to @new_bs, including + * checking and applying the necessary permisson updates both to the old n= ode + * and to @new_bs. + * + * NULL is passed as @new_bs for removing the reference before freeing @ch= ild. + * + * If @new_bs is not NULL, bdrv_check_perm() must be called beforehand, as= this + * function uses bdrv_set_perm() to update the permissions according to th= e new + * reference that @new_bs gets. + */ +static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs) { BlockDriverState *old_bs =3D child->bs; uint64_t perm, shared_perm; @@ -1775,9 +1785,6 @@ static void bdrv_replace_child(BdrvChild *child, Bloc= kDriverState *new_bs, =20 if (new_bs) { bdrv_get_cumulative_perm(new_bs, &perm, &shared_perm); - if (check_new_perm) { - bdrv_check_perm(new_bs, perm, shared_perm, NULL, &error_abort); - } bdrv_set_perm(new_bs, perm, shared_perm); } } @@ -1808,7 +1815,7 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *c= hild_bs, }; =20 /* This performs the matching bdrv_set_perm() for the above check. */ - bdrv_replace_child(child, child_bs, false); + bdrv_replace_child(child, child_bs); =20 return child; } @@ -1845,7 +1852,7 @@ static void bdrv_detach_child(BdrvChild *child) child->next.le_prev =3D NULL; } =20 - bdrv_replace_child(child, NULL, false); + bdrv_replace_child(child, NULL); =20 g_free(child->name); g_free(child); --=20 1.8.3.1 From nobody Thu Nov 6 14:05:17 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489417005734797.5656599295551; Mon, 13 Mar 2017 07:56:45 -0700 (PDT) Received: from localhost ([::1]:52497 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnROu-0005y6-Ee for importer@patchew.org; Mon, 13 Mar 2017 10:56:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRNk-0005oo-B7 for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnRNj-0002xt-N1 for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51018) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnRNf-0002us-15; Mon, 13 Mar 2017 10:55:27 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1D6C683F46; Mon, 13 Mar 2017 14:55:27 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-150.ams2.redhat.com [10.36.117.150]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2DEtEUa009408; Mon, 13 Mar 2017 10:55:26 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 13 Mar 2017 15:55:04 +0100 Message-Id: <1489416908-3771-9-git-send-email-kwolf@redhat.com> In-Reply-To: <1489416908-3771-1-git-send-email-kwolf@redhat.com> References: <1489416908-3771-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 13 Mar 2017 14:55:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 08/12] block: Request block status from *file for BDRV_BLOCK_RAW X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This fixes bdrv_co_get_block_status() for the bdrv_mirror_top block driver, which must fall through to bs->backing instead of bs->file. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/io.c b/block/io.c index 8f38d46..2709a70 100644 --- a/block/io.c +++ b/block/io.c @@ -1760,7 +1760,7 @@ static int64_t coroutine_fn bdrv_co_get_block_status(= BlockDriverState *bs, =20 if (ret & BDRV_BLOCK_RAW) { assert(ret & BDRV_BLOCK_OFFSET_VALID); - ret =3D bdrv_get_block_status(bs->file->bs, ret >> BDRV_SECTOR_BIT= S, + ret =3D bdrv_get_block_status(*file, ret >> BDRV_SECTOR_BITS, *pnum, pnum, file); goto out; } --=20 1.8.3.1 From nobody Thu Nov 6 14:05:17 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 148941728760635.484754770992936; Mon, 13 Mar 2017 08:01:27 -0700 (PDT) Received: from localhost ([::1]:52528 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRTQ-0001Yr-4Q for importer@patchew.org; Mon, 13 Mar 2017 11:01:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRNk-0005pF-Oc for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnRNj-0002y3-P5 for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56126) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnRNg-0002vZ-CA; Mon, 13 Mar 2017 10:55:28 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7419B6AAFD; Mon, 13 Mar 2017 14:55:28 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-150.ams2.redhat.com [10.36.117.150]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2DEtEUb009408; Mon, 13 Mar 2017 10:55:27 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 13 Mar 2017 15:55:05 +0100 Message-Id: <1489416908-3771-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1489416908-3771-1-git-send-email-kwolf@redhat.com> References: <1489416908-3771-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 13 Mar 2017 14:55:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/12] commit: Implement bdrv_commit_top.bdrv_co_get_block_status X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In some cases, bdrv_co_get_block_status() is called recursively for the whole backing chain. The automatically inserted bdrv_commit_top filter driver must not stop the recursion, so implement a callback that simply forwards the request to bs->backing. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block/commit.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/block/commit.c b/block/commit.c index 9c41988..932d1e6 100644 --- a/block/commit.c +++ b/block/commit.c @@ -232,6 +232,17 @@ static int coroutine_fn bdrv_commit_top_preadv(BlockDr= iverState *bs, return bdrv_co_preadv(bs->backing, offset, bytes, qiov, flags); } =20 +static int64_t coroutine_fn bdrv_commit_top_get_block_status( + BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum, + BlockDriverState **file) +{ + *pnum =3D nb_sectors; + *file =3D bs->backing->bs; + return BDRV_BLOCK_RAW | BDRV_BLOCK_OFFSET_VALID | BDRV_BLOCK_DATA | + (sector_num << BDRV_SECTOR_BITS); +} + + static void bdrv_commit_top_close(BlockDriverState *bs) { } @@ -248,10 +259,11 @@ static void bdrv_commit_top_child_perm(BlockDriverSta= te *bs, BdrvChild *c, /* Dummy node that provides consistent read to its users without requiring= it * from its backing file and that allows writes on the backing file chain.= */ static BlockDriver bdrv_commit_top =3D { - .format_name =3D "commit_top", - .bdrv_co_preadv =3D bdrv_commit_top_preadv, - .bdrv_close =3D bdrv_commit_top_close, - .bdrv_child_perm =3D bdrv_commit_top_child_perm, + .format_name =3D "commit_top", + .bdrv_co_preadv =3D bdrv_commit_top_preadv, + .bdrv_co_get_block_status =3D bdrv_commit_top_get_block_status, + .bdrv_close =3D bdrv_commit_top_close, + .bdrv_child_perm =3D bdrv_commit_top_child_perm, }; =20 void commit_start(const char *job_id, BlockDriverState *bs, --=20 1.8.3.1 From nobody Thu Nov 6 14:05:17 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 148941714631968.48849855048286; Mon, 13 Mar 2017 07:59:06 -0700 (PDT) Received: from localhost ([::1]:52509 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRR9-0007u1-55 for importer@patchew.org; Mon, 13 Mar 2017 10:59:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35290) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRNk-0005pQ-Uv for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnRNk-0002yO-5w for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43429) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnRNh-0002w4-LV; Mon, 13 Mar 2017 10:55:29 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BA508770A; Mon, 13 Mar 2017 14:55:29 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-150.ams2.redhat.com [10.36.117.150]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2DEtEUc009408; Mon, 13 Mar 2017 10:55:28 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 13 Mar 2017 15:55:06 +0100 Message-Id: <1489416908-3771-11-git-send-email-kwolf@redhat.com> In-Reply-To: <1489416908-3771-1-git-send-email-kwolf@redhat.com> References: <1489416908-3771-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 13 Mar 2017 14:55:29 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 10/12] block: Refresh filename after changing backing file X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In bdrv_open_inherit(), the filename is refreshed after opening the backing file, but we neglected to do the same when the backing file changes later. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block.c b/block.c index dd38e71..cb57370 100644 --- a/block.c +++ b/block.c @@ -1938,6 +1938,8 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockD= riverState *backing_hd, bdrv_unref(backing_hd); } =20 + bdrv_refresh_filename(bs); + out: bdrv_refresh_limits(bs, NULL); } --=20 1.8.3.1 From nobody Thu Nov 6 14:05:17 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489417568357904.3503129509241; Mon, 13 Mar 2017 08:06:08 -0700 (PDT) Received: from localhost ([::1]:52554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRXv-0005Oc-R6 for importer@patchew.org; Mon, 13 Mar 2017 11:06:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRNl-0005r0-UU for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnRNl-0002zT-8X for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35230) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnRNj-0002wE-24; Mon, 13 Mar 2017 10:55:31 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1370181F07; Mon, 13 Mar 2017 14:55:31 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-150.ams2.redhat.com [10.36.117.150]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2DEtEUd009408; Mon, 13 Mar 2017 10:55:30 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 13 Mar 2017 15:55:07 +0100 Message-Id: <1489416908-3771-12-git-send-email-kwolf@redhat.com> In-Reply-To: <1489416908-3771-1-git-send-email-kwolf@redhat.com> References: <1489416908-3771-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 13 Mar 2017 14:55:31 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 11/12] mirror: Implement .bdrv_refresh_filename X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We want query-block to return the right filename, even if a mirror job put a bdrv_mirror_top on top of the actual image format driver. Let bdrv_mirror_top.bdrv_refresh_filename get the filename from its backing file. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block/mirror.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/block/mirror.c b/block/mirror.c index a5d30ee..4f3a5cb 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -12,6 +12,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/cutils.h" #include "trace.h" #include "block/blockjob_int.h" #include "block/block_int.h" @@ -1060,6 +1061,13 @@ static int coroutine_fn bdrv_mirror_top_pdiscard(Blo= ckDriverState *bs, return bdrv_co_pdiscard(bs->backing->bs, offset, count); } =20 +static void bdrv_mirror_top_refresh_filename(BlockDriverState *bs, QDict *= opts) +{ + bdrv_refresh_filename(bs->backing->bs); + pstrcpy(bs->exact_filename, sizeof(bs->exact_filename), + bs->backing->bs->filename); +} + static void bdrv_mirror_top_close(BlockDriverState *bs) { } @@ -1088,6 +1096,7 @@ static BlockDriver bdrv_mirror_top =3D { .bdrv_co_pdiscard =3D bdrv_mirror_top_pdiscard, .bdrv_co_flush =3D bdrv_mirror_top_flush, .bdrv_co_get_block_status =3D bdrv_mirror_top_get_block_status, + .bdrv_refresh_filename =3D bdrv_mirror_top_refresh_filename, .bdrv_close =3D bdrv_mirror_top_close, .bdrv_child_perm =3D bdrv_mirror_top_child_perm, }; --=20 1.8.3.1 From nobody Thu Nov 6 14:05:17 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489417146287604.5461327033414; Mon, 13 Mar 2017 07:59:06 -0700 (PDT) Received: from localhost ([::1]:52510 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRRA-0007ut-Tu for importer@patchew.org; Mon, 13 Mar 2017 10:59:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRNn-0005sP-57 for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnRNm-00030D-El for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9475) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnRNk-0002xx-A0; Mon, 13 Mar 2017 10:55:32 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5E3CD81243; Mon, 13 Mar 2017 14:55:32 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-150.ams2.redhat.com [10.36.117.150]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2DEtEUe009408; Mon, 13 Mar 2017 10:55:31 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 13 Mar 2017 15:55:08 +0100 Message-Id: <1489416908-3771-13-git-send-email-kwolf@redhat.com> In-Reply-To: <1489416908-3771-1-git-send-email-kwolf@redhat.com> References: <1489416908-3771-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 13 Mar 2017 14:55:32 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 12/12] commit: Implement .bdrv_refresh_filename X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We want query-block to return the right filename, even if a commit job put a bdrv_commit_top on top of the actual image format driver. Let bdrv_commit_top.bdrv_refresh_filename get the filename from its backing file. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block/commit.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/block/commit.c b/block/commit.c index 932d1e6..2832482 100644 --- a/block/commit.c +++ b/block/commit.c @@ -13,6 +13,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/cutils.h" #include "trace.h" #include "block/block_int.h" #include "block/blockjob_int.h" @@ -242,6 +243,12 @@ static int64_t coroutine_fn bdrv_commit_top_get_block_= status( (sector_num << BDRV_SECTOR_BITS); } =20 +static void bdrv_commit_top_refresh_filename(BlockDriverState *bs, QDict *= opts) +{ + bdrv_refresh_filename(bs->backing->bs); + pstrcpy(bs->exact_filename, sizeof(bs->exact_filename), + bs->backing->bs->filename); +} =20 static void bdrv_commit_top_close(BlockDriverState *bs) { @@ -262,6 +269,7 @@ static BlockDriver bdrv_commit_top =3D { .format_name =3D "commit_top", .bdrv_co_preadv =3D bdrv_commit_top_preadv, .bdrv_co_get_block_status =3D bdrv_commit_top_get_block_status, + .bdrv_refresh_filename =3D bdrv_commit_top_refresh_filename, .bdrv_close =3D bdrv_commit_top_close, .bdrv_child_perm =3D bdrv_commit_top_child_perm, }; --=20 1.8.3.1