From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, den@openvz.org, vsementsov@virtuozzo.com,
dautovri@hpcdlab.com
Subject: [PATCH 3/5] block/prl-xml: add bdrv_probe
Date: Fri, 13 Nov 2020 15:58:46 +0300 [thread overview]
Message-ID: <20201113125848.20498-4-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20201113125848.20498-1-vsementsov@virtuozzo.com>
From: Klim Kireev <klim.kireev@virtuozzo.com>
This commit adds bdrv_probe implementation.
It checks the filename (it must be DiskDescriptor.xml).
Then it checks correctness of the xml file using libxml2.
Signed-off-by: Klim Kireev <klim.kireev@virtuozzo.com>
---
block/prl-xml.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/block/prl-xml.c b/block/prl-xml.c
index 5ab32bb6ab..023651342c 100644
--- a/block/prl-xml.c
+++ b/block/prl-xml.c
@@ -467,6 +467,30 @@ fail:
return ret;
}
+static int prl_probe_xml(const uint8_t *data, int buf_size,
+ const char *filename)
+{
+ xmlDoc *doc = NULL;
+ xmlNodePtr root;
+
+ if (strcmp(basename(filename), PRL_XML_FILENAME) != 0) {
+ return 0;
+ }
+
+ doc = xmlReadFile(filename, NULL, XML_PARSE_NOERROR | XML_PARSE_NOWARNING);
+ if (doc == NULL) {
+ return 0;
+ }
+
+ root = xmlDocGetRootElement(doc);
+ if (root == NULL) {
+ return 0;
+ }
+
+ xmlFreeDoc(doc);
+ return 100;
+}
+
static coroutine_fn int
prl_co_readv(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, QEMUIOVector *qiov)
@@ -499,6 +523,7 @@ static coroutine_fn int prl_co_flush_to_os(BlockDriverState *bs)
static BlockDriver bdrv_prl_xml = {
.format_name = "prl-xml",
.instance_size = sizeof(BDRVPrlXmlState),
+ .bdrv_probe = prl_probe_xml,
.bdrv_open = prl_open_xml,
.bdrv_co_readv = prl_co_readv,
.bdrv_co_writev = prl_co_writev,
--
2.21.3
next prev parent reply other threads:[~2020-11-13 13:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-13 12:58 [PATCH RFC 0/5] block: implement Parallels Disk format driver Vladimir Sementsov-Ogievskiy
2020-11-13 12:58 ` [PATCH 1/5] block/prl-xml: add Parallels xml BlockDriver Vladimir Sementsov-Ogievskiy
2020-11-13 12:58 ` [PATCH 2/5] block/prl-xml: add bdrv_co_readv/writev and flush Vladimir Sementsov-Ogievskiy
2020-11-13 12:58 ` Vladimir Sementsov-Ogievskiy [this message]
2020-11-13 12:58 ` [PATCH 4/5] block/prl-xml: add bdrv_check Vladimir Sementsov-Ogievskiy
2020-11-13 12:58 ` [PATCH 5/5] iotests: add test for prl-xml format Vladimir Sementsov-Ogievskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201113125848.20498-4-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=dautovri@hpcdlab.com \
--cc=den@openvz.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).