[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v2 04/15] sheepdog: Mark sd_snapshot_delete() lossag
From: |
Markus Armbruster |
Subject: |
[Qemu-block] [PATCH v2 04/15] sheepdog: Mark sd_snapshot_delete() lossage FIXME |
Date: |
Mon, 6 Mar 2017 20:00:38 +0100 |
sd_snapshot_delete() should delete the snapshot whose ID matches
@snapshot_id and whose name matches @name. But that's not what it
does. If @snapshot_id is a valid ID, it deletes the snapshot with
that ID, else it deletes the snapshot with that name. It doesn't use
@name at all. Add suitable FIXME comments, so someone who actually
knows Sheepdog can fix it.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
block/sheepdog.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index be3db1f..187bcd8 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -2457,6 +2457,10 @@ static int sd_snapshot_delete(BlockDriverState *bs,
const char *name,
Error **errp)
{
+ /*
+ * FIXME should delete the snapshot matching both @snapshot_id and
+ * @name, but @name not used here
+ */
unsigned long snap_id = 0;
char snap_tag[SD_MAX_VDI_TAG_LEN];
int fd, ret;
@@ -2481,6 +2485,11 @@ static int sd_snapshot_delete(BlockDriverState *bs,
pstrcpy(buf, SD_MAX_VDI_LEN, s->name);
ret = qemu_strtoul(snapshot_id, NULL, 10, &snap_id);
if (ret || snap_id > UINT32_MAX) {
+ /*
+ * FIXME Since qemu_strtoul() returns -EINVAL when
+ * @snapshot_id is null, @snapshot_id is mandatory. Correct
+ * would be to require at least one of @snapshot_id and @name.
+ */
error_setg(errp, "Invalid snapshot ID: %s",
snapshot_id ? snapshot_id : "<null>");
return -EINVAL;
@@ -2489,6 +2498,7 @@ static int sd_snapshot_delete(BlockDriverState *bs,
if (snap_id) {
hdr.snapid = (uint32_t) snap_id;
} else {
+ /* FIXME I suspect we should use @name here */
pstrcpy(snap_tag, sizeof(snap_tag), snapshot_id);
pstrcpy(buf + SD_MAX_VDI_LEN, SD_MAX_VDI_TAG_LEN, snap_tag);
}
--
2.7.4
- [Qemu-block] [PATCH v2 00/15] block: A bunch of fixes for Sheepdog and Gluster, Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 04/15] sheepdog: Mark sd_snapshot_delete() lossage FIXME,
Markus Armbruster <=
- [Qemu-block] [PATCH v2 02/15] sheepdog: Fix error handling in sd_snapshot_delete(), Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 03/15] sheepdog: Fix error handling sd_create(), Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 01/15] sheepdog: Defuse time bomb in sd_open() error handling, Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 08/15] sheepdog: Use SocketAddress and socket_connect(), Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 10/15] gluster: Drop assumptions on SocketTransport names, Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 06/15] sheepdog: Don't truncate long VDI name in _open(), _create(), Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 05/15] sheepdog: Fix snapshot ID parsing in _open(), _create, _goto(), Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 12/15] gluster: Plug memory leaks in qemu_gluster_parse_json(), Markus Armbruster, 2017/03/06