aboutsummaryrefslogtreecommitdiff
path: root/hw/block-common.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2012-07-11 15:08:37 +0200
committerKevin Wolf <kwolf@redhat.com>2012-07-17 16:48:32 +0200
commit911525dba9ecc21f97b05c0f09bf9319a9de3a7d (patch)
tree5d82736bd710e29d590d841bd2636d4247085eff /hw/block-common.c
parent31e404f4ffb6adadea0b35de08e0a6b640e81a02 (diff)
hw/block-common: Factor out fall back to legacy -drive serial=...
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/block-common.c')
-rw-r--r--hw/block-common.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/hw/block-common.c b/hw/block-common.c
new file mode 100644
index 0000000000..036334b1ec
--- /dev/null
+++ b/hw/block-common.c
@@ -0,0 +1,24 @@
+/*
+ * Common code for block device models
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * later. See the COPYING file in the top-level directory.
+ */
+
+#include "blockdev.h"
+#include "hw/block-common.h"
+
+void blkconf_serial(BlockConf *conf, char **serial)
+{
+ DriveInfo *dinfo;
+
+ if (!*serial) {
+ /* try to fall back to value set with legacy -drive serial=... */
+ dinfo = drive_get_by_blockdev(conf->bs);
+ if (*dinfo->serial) {
+ *serial = g_strdup(dinfo->serial);
+ }
+ }
+}