|
|
ae23c9 |
From 1920bc35d149d2b28658e5354468df407c9799f1 Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
Date: Thu, 5 Jul 2018 16:47:51 +0200
|
|
|
ae23c9 |
Subject: [PATCH 190/268] block: Don't silently truncate node names
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
Message-id: <20180705164751.15271-2-kwolf@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 81234
|
|
|
ae23c9 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 1/1] block: Don't silently truncate node names
|
|
|
ae23c9 |
Bugzilla: 1549654
|
|
|
ae23c9 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
If the user passes a too long node name string, we silently truncate it
|
|
|
ae23c9 |
to fit into BlockDriverState.node_name, i.e. to 31 characters. Apart
|
|
|
ae23c9 |
from surprising the user when the node has a different name than
|
|
|
ae23c9 |
requested, this also bypasses the check for duplicate names, so that the
|
|
|
ae23c9 |
same name can be assigned to multiple nodes.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Fix this by just making too long node names an error.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Reported-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit 824808dd77821ceba05357cb1ee4069a6a95bebd)
|
|
|
ae23c9 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
block.c | 6 ++++++
|
|
|
ae23c9 |
tests/qemu-iotests/051 | 15 +++++++++++++++
|
|
|
ae23c9 |
tests/qemu-iotests/051.out | 23 +++++++++++++++++++++++
|
|
|
ae23c9 |
tests/qemu-iotests/051.pc.out | 23 +++++++++++++++++++++++
|
|
|
ae23c9 |
4 files changed, 67 insertions(+)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/block.c b/block.c
|
|
|
ae23c9 |
index afe30ca..0516284 100644
|
|
|
ae23c9 |
--- a/block.c
|
|
|
ae23c9 |
+++ b/block.c
|
|
|
ae23c9 |
@@ -1140,6 +1140,12 @@ static void bdrv_assign_node_name(BlockDriverState *bs,
|
|
|
ae23c9 |
goto out;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+ /* Make sure that the node name isn't truncated */
|
|
|
ae23c9 |
+ if (strlen(node_name) >= sizeof(bs->node_name)) {
|
|
|
ae23c9 |
+ error_setg(errp, "Node name too long");
|
|
|
ae23c9 |
+ goto out;
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
/* copy node name into the bs and insert it into the graph list */
|
|
|
ae23c9 |
pstrcpy(bs->node_name, sizeof(bs->node_name), node_name);
|
|
|
ae23c9 |
QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list);
|
|
|
ae23c9 |
diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051
|
|
|
ae23c9 |
index 69d34eb..c5cc0ee 100755
|
|
|
ae23c9 |
--- a/tests/qemu-iotests/051
|
|
|
ae23c9 |
+++ b/tests/qemu-iotests/051
|
|
|
ae23c9 |
@@ -100,6 +100,21 @@ run_qemu -drive file="$TEST_IMG",driver=raw,format=qcow2
|
|
|
ae23c9 |
run_qemu -drive file="$TEST_IMG",driver=qcow2,format=qcow2
|
|
|
ae23c9 |
|
|
|
ae23c9 |
echo
|
|
|
ae23c9 |
+echo === Node names ===
|
|
|
ae23c9 |
+echo
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+# Maximum length: 31 characters
|
|
|
ae23c9 |
+run_qemu -drive file="$TEST_IMG",node-name=x123456789012345678901234567890
|
|
|
ae23c9 |
+run_qemu -drive file="$TEST_IMG",node-name=x1234567890123456789012345678901
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+# First character must be alphabetic
|
|
|
ae23c9 |
+# Following characters alphanumeric or -._
|
|
|
ae23c9 |
+run_qemu -drive file="$TEST_IMG",node-name=All-Types.of_all0wed_chars
|
|
|
ae23c9 |
+run_qemu -drive file="$TEST_IMG",node-name=123foo
|
|
|
ae23c9 |
+run_qemu -drive file="$TEST_IMG",node-name=_foo
|
|
|
ae23c9 |
+run_qemu -drive file="$TEST_IMG",node-name=foo#12
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+echo
|
|
|
ae23c9 |
echo === Device without drive ===
|
|
|
ae23c9 |
echo
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/tests/qemu-iotests/051.out b/tests/qemu-iotests/051.out
|
|
|
ae23c9 |
index dd9846d..b727350 100644
|
|
|
ae23c9 |
--- a/tests/qemu-iotests/051.out
|
|
|
ae23c9 |
+++ b/tests/qemu-iotests/051.out
|
|
|
ae23c9 |
@@ -47,6 +47,29 @@ Testing: -drive file=TEST_DIR/t.qcow2,driver=qcow2,format=qcow2
|
|
|
ae23c9 |
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,driver=qcow2,format=qcow2: Cannot specify both 'driver' and 'format'
|
|
|
ae23c9 |
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+=== Node names ===
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+Testing: -drive file=TEST_DIR/t.qcow2,node-name=x123456789012345678901234567890
|
|
|
ae23c9 |
+QEMU X.Y.Z monitor - type 'help' for more information
|
|
|
ae23c9 |
+(qemu) quit
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+Testing: -drive file=TEST_DIR/t.qcow2,node-name=x1234567890123456789012345678901
|
|
|
ae23c9 |
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=x1234567890123456789012345678901: Node name too long
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+Testing: -drive file=TEST_DIR/t.qcow2,node-name=All-Types.of_all0wed_chars
|
|
|
ae23c9 |
+QEMU X.Y.Z monitor - type 'help' for more information
|
|
|
ae23c9 |
+(qemu) quit
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+Testing: -drive file=TEST_DIR/t.qcow2,node-name=123foo
|
|
|
ae23c9 |
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=123foo: Invalid node name
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+Testing: -drive file=TEST_DIR/t.qcow2,node-name=_foo
|
|
|
ae23c9 |
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=_foo: Invalid node name
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+Testing: -drive file=TEST_DIR/t.qcow2,node-name=foo#12
|
|
|
ae23c9 |
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=foo#12: Invalid node name
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
=== Device without drive ===
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Testing: -device VIRTIO_SCSI -device scsi-hd
|
|
|
ae23c9 |
diff --git a/tests/qemu-iotests/051.pc.out b/tests/qemu-iotests/051.pc.out
|
|
|
ae23c9 |
index b01f9a9..e9257fe 100644
|
|
|
ae23c9 |
--- a/tests/qemu-iotests/051.pc.out
|
|
|
ae23c9 |
+++ b/tests/qemu-iotests/051.pc.out
|
|
|
ae23c9 |
@@ -47,6 +47,29 @@ Testing: -drive file=TEST_DIR/t.qcow2,driver=qcow2,format=qcow2
|
|
|
ae23c9 |
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,driver=qcow2,format=qcow2: Cannot specify both 'driver' and 'format'
|
|
|
ae23c9 |
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+=== Node names ===
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+Testing: -drive file=TEST_DIR/t.qcow2,node-name=x123456789012345678901234567890
|
|
|
ae23c9 |
+QEMU X.Y.Z monitor - type 'help' for more information
|
|
|
ae23c9 |
+(qemu) quit
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+Testing: -drive file=TEST_DIR/t.qcow2,node-name=x1234567890123456789012345678901
|
|
|
ae23c9 |
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=x1234567890123456789012345678901: Node name too long
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+Testing: -drive file=TEST_DIR/t.qcow2,node-name=All-Types.of_all0wed_chars
|
|
|
ae23c9 |
+QEMU X.Y.Z monitor - type 'help' for more information
|
|
|
ae23c9 |
+(qemu) quit
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+Testing: -drive file=TEST_DIR/t.qcow2,node-name=123foo
|
|
|
ae23c9 |
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=123foo: Invalid node name
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+Testing: -drive file=TEST_DIR/t.qcow2,node-name=_foo
|
|
|
ae23c9 |
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=_foo: Invalid node name
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+Testing: -drive file=TEST_DIR/t.qcow2,node-name=foo#12
|
|
|
ae23c9 |
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=foo#12: Invalid node name
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
=== Device without drive ===
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Testing: -device VIRTIO_SCSI -device scsi-hd
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|