Xen queue

* xen-block fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQFOBAABCgA4FiEE+AwAYwjiLP2KkueYDPVXL9f7Va8FAlx4GtkaHGFudGhvbnku
 cGVyYXJkQGNpdHJpeC5jb20ACgkQDPVXL9f7Va+/wggApsFiI6zKHuBQFIZfO8l0
 xv2T8hC3bPyalQiYDS73CcoadjrG/SjqEkHIWLL+KRMTM1pRwdbSbyaGJELCMsKo
 xyJZB7gu0MY40/wGIigc3/KxuW4+uvJfUj819pbR5CGNSbIgAJpwwC4iS/ve9L/O
 KBq4Bj42mn1jM/rjEQ4U+wfg/lGDom84TUDT2t9JYfskm+jSPODxo6QA2iZ3dN4x
 tP3rLbvkoUUlcYW5mWnS3LibusFM5YGXvL8Xvw8SHqBDF0SmesPp+B0dYF//Qw5Y
 7Oo89gJApFWrLSmaq2+NF4+ZvxJFOKHmGnlMge+gEYqVzBu+tuSuMutwrXK+C9Nl
 yA==
 =woNs
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/aperard/tags/pull-xen-20190228' into staging

Xen queue

* xen-block fixes

# gpg: Signature made Thu 28 Feb 2019 17:31:05 GMT
# gpg:                using RSA key F80C006308E22CFD8A92E7980CF5572FD7FB55AF
# gpg:                issuer "anthony.perard@citrix.com"
# gpg: Good signature from "Anthony PERARD <anthony.perard@gmail.com>" [marginal]
# gpg:                 aka "Anthony PERARD <anthony.perard@citrix.com>" [marginal]
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 5379 2F71 024C 600F 778A  7161 D8D5 7199 DF83 42C8
#      Subkey fingerprint: F80C 0063 08E2 2CFD 8A92  E798 0CF5 572F D7FB 55AF

* remotes/aperard/tags/pull-xen-20190228:
  xen-block: stop leaking memory in xen_block_drive_create()
  xen-block: report error condition from vbd_name_to_disk()
  xen-block: remove redundant assignment
  dataplane/xen-block: remove dead code

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2019-03-01 10:38:06 +00:00
commit f0ce2e17cd
2 changed files with 26 additions and 19 deletions

View File

@ -281,10 +281,6 @@ static void xen_block_complete_aio(void *opaque, int ret)
break;
case BLKIF_OP_WRITE:
case BLKIF_OP_FLUSH_DISKCACHE:
if (!request->req.nr_segments) {
break;
}
break;
default:
break;
}
@ -298,6 +294,7 @@ static void xen_block_complete_aio(void *opaque, int ret)
if (!request->req.nr_segments) {
break;
}
/* fall through */
case BLKIF_OP_READ:
if (request->status == BLKIF_RSP_OKAY) {
block_acct_done(blk_get_stats(dataplane->blk), &request->acct);

View File

@ -351,21 +351,28 @@ static void xen_block_get_vdev(Object *obj, Visitor *v, const char *name,
g_free(str);
}
static unsigned int vbd_name_to_disk(const char *name, const char **endp)
static int vbd_name_to_disk(const char *name, const char **endp,
unsigned long *disk)
{
unsigned int disk = 0;
unsigned int n = 0;
while (*name != '\0') {
if (!g_ascii_isalpha(*name) || !g_ascii_islower(*name)) {
break;
}
disk *= 26;
disk += *name++ - 'a' + 1;
n *= 26;
n += *name++ - 'a' + 1;
}
*endp = name;
return disk - 1;
if (!n) {
return -1;
}
*disk = n - 1;
return 0;
}
static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name,
@ -413,13 +420,14 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name,
}
if (*end == 'p') {
p = (char *) ++end;
if (*end == '\0') {
if (*(++end) == '\0') {
goto invalid;
}
}
} else {
vdev->disk = vbd_name_to_disk(p, &end);
if (vbd_name_to_disk(p, &end, &vdev->disk)) {
goto invalid;
}
}
if (*end != '\0') {
@ -735,12 +743,12 @@ static XenBlockDrive *xen_block_drive_create(const char *id,
}
g_strfreev(v);
}
if (!filename) {
error_setg(errp, "no filename");
} else {
error_setg(errp, "no params");
goto done;
}
assert(filename);
assert(driver);
drive = g_new0(XenBlockDrive, 1);
@ -750,6 +758,7 @@ static XenBlockDrive *xen_block_drive_create(const char *id,
qdict_put_str(file_layer, "driver", "file");
qdict_put_str(file_layer, "filename", filename);
g_free(filename);
if (mode && *mode != 'w') {
qdict_put_bool(file_layer, "read-only", true);
@ -785,16 +794,17 @@ static XenBlockDrive *xen_block_drive_create(const char *id,
driver_layer = qdict_new();
qdict_put_str(driver_layer, "driver", driver);
g_free(driver);
qdict_put_obj(driver_layer, "file", QOBJECT(file_layer));
g_assert(!drive->node_name);
drive->node_name = xen_block_blockdev_add(drive->id, driver_layer,
&local_err);
done:
g_free(driver);
g_free(filename);
qobject_unref(driver_layer);
done:
if (local_err) {
error_propagate(errp, local_err);
xen_block_drive_destroy(drive, NULL);