search for: xmltextwriterstartelement

Displaying 20 results from an estimated 49 matches for "xmltextwriterstartelement".

2014 Jan 17
0
[PATCH INCOMPLETE] launch: libvirt: Use C macros to simplify XML generation.
This commit implements some hairy C macros to simplify XML generation. Given the target XML: <cpu mode="host-passthrough"> <model fallback="allow"/> </cpu> The old code would have looked like this: XMLERROR (-1, xmlTextWriterStartElement (xo, BAD_CAST "cpu")); XMLERROR (-1, xmlTextWriterWriteAttribute (xo, BAD_CAST "mode", BAD_CAST "host-passthrough")); XMLERROR (-1, xmlTextWriterStartElement (xo, BAD_CAST "model")); XMLERROR (-1,...
2012 Jul 21
8
[PATCH libguestfs 0/4] Add a libvirt backend to libguestfs.
This preliminary patch series adds a libvirt backend to libguestfs. It's for review only because although it launches the guest OK, there are some missing features that need to be implemented. The meat of the patch is in part 4/4. To save you the trouble of interpreting libxml2 fragments, an example of the generated XML and the corresponding qemu command line are attached below. Note the
2012 Mar 31
2
[PATCH v6] hivexml: Add byte run reporting functions
...+ size_t node_struct_length = hivex_node_struct_length (h, node); + if (errno) { + if (errno == EINVAL) { + fprintf (stderr, "node_byte_runs: Invoked on what does not seem to be a node (%zu).\n", node); + } + return -1; + } + /* A node has one byte run. */ + XML_CHECK (xmlTextWriterStartElement, (writer, BAD_CAST "byte_runs")); + XML_CHECK (xmlTextWriterStartElement, (writer, BAD_CAST "byte_run")); + memset (buf, 0, 1+BYTE_RUN_BUF_LEN); + snprintf (buf, 1+BYTE_RUN_BUF_LEN, "%zu", node); + XML_CHECK (xmlTextWriterWriteAttribute, (writer, BAD_CAST "fil...
2018 Oct 04
0
[PATCH v2 3/4] inspector: Use libxml writer macros.
...roots); - XMLERROR (-1, xmlTextWriterEndDocument (xo)); + + if (xmlTextWriterEndDocument (xo) == -1) + error (EXIT_FAILURE, errno, "xmlTextWriterEndDocument"); } static void @@ -340,10 +349,10 @@ output_roots (xmlTextWriterPtr xo, char **roots) { size_t i; - XMLERROR (-1, xmlTextWriterStartElement (xo, BAD_CAST "operatingsystems")); - for (i = 0; roots[i] != NULL; ++i) - output_root (xo, roots[i]); - XMLERROR (-1, xmlTextWriterEndElement (xo)); + start_element ("operatingsystems") { + for (i = 0; roots[i] != NULL; ++i) + output_root (xo, roots[i]); + } end_...
2011 Sep 17
3
[PATCH 1/1] hivexml: Base64-encode non-printable data
...lse + ret = -1; + return ret; +} + static int node_start (hive_h *h, void *writer_v, hive_node_h node, const char *name) { @@ -210,7 +257,10 @@ node_start (hive_h *h, void *writer_v, hive_node_h node, const char *name) xmlTextWriterPtr writer = (xmlTextWriterPtr) writer_v; XML_CHECK (xmlTextWriterStartElement, (writer, BAD_CAST "node")); - XML_CHECK (xmlTextWriterWriteAttribute, (writer, BAD_CAST "name", BAD_CAST name)); + + ret = safe_print_string_attribute (h, writer_v, "name", "name_encoding", name); + if (ret) + fprintf (stderr, "Warning: node_start...
2018 Nov 02
7
[PATCH v3 0/4] common/utils: Move libxml2 writer macros to a common header file.
v1 was here: https://www.redhat.com/archives/libguestfs/2018-October/msg00047.html v2 was here: https://www.redhat.com/archives/libguestfs/2018-October/msg00051.html v3: - Back to using string/string_format and attribute/attribute_format. - Add both single_element and single_element_format. - Rebased and retested. Rich.
2018 Oct 04
2
[PATCH 0/2] Use common macros to help with libxml2 writer.
Consolidate and extend the use of funky start_element() etc macros. Rich.
2018 Nov 02
0
[PATCH v3 2/4] common/utils: Move libxml2 writer macros to a common header file.
...XML2_WRITER_MACROS_H_ + +#include <stdarg.h> + +/** + * To define an XML element use: + * + * start_element ("name") { + * ... + * } end_element (); + * + * which produces C<<< <name>...</name> >>> + */ +#define start_element(element) \ + if (xmlTextWriterStartElement (xo, BAD_CAST (element)) == -1) { \ + xml_error ("xmlTextWriterStartElement"); \ + } \ + do + +#define end_element() \ + while (0); \ + do { \ + if (xmlTextWriterEndElement (xo) == -1) { \ + xml_error ("xmlTextWriterEndElement"); \ + }...
2011 Dec 08
1
[hivex] [PATCH 8/8] hivexml: Add byte run reporting functions
...+ size_t node_struct_length = hivex_node_struct_length (h, node); + if (errno) { + if (errno == EINVAL) { + fprintf (stderr, "node_byte_runs: Invoked on what does not seem to be a node (%zu).\n", node); + } + return -1; + } + /* A node has one byte run. */ + XML_CHECK (xmlTextWriterStartElement, (writer, BAD_CAST "byte_runs")); + XML_CHECK (xmlTextWriterStartElement, (writer, BAD_CAST "byte_run")); + memset (buf, 0, 1+BYTE_RUN_BUF_LEN); + snprintf (buf, 1+BYTE_RUN_BUF_LEN, "%d", node); + XML_CHECK (xmlTextWriterWriteAttribute, (writer, BAD_CAST "file...
2014 Jan 16
3
[PATCH 0/2] Don't use snapshot=on
QEMU upstream has broken snapshot=on ... again. These two patches stop using it entirely. Instead we run 'qemu-img create' to create overlay disks as required. Note that the libvirt and UML backends were already doing this: The libvirt backend because <transient/> has never worked, and the UML backend was running uml_mkcow because the UML-equivalent syntax of snapshot=on was
2018 Oct 04
6
[PATCH v2 0/4] common/utils: Move libxml2 writer macros to a common header file.
v1 was here: https://www.redhat.com/archives/libguestfs/2018-October/msg00047.html However it was broken in a few ways. First of all the documentation was broken because "/**" enhanced comments were not permitted on macros. This is fixed in the new 1/4 patch. Secondly we didn't use single_element() everywhere possible, which is fixed in the new 4/4 patch. Lastly I've
2012 Feb 01
1
[PATCH] hivexml
...const char *name) > { > int64_t last_modified; > @@ -265,6 +282,20 @@ end_value (xmlTextWriterPtr writer) > XML_CHECK (xmlTextWriterEndElement, (writer)); > } > > +static void > +start_string(xmlTextWriterPtr writer, const char *encoding) > +{ > + XML_CHECK (xmlTextWriterStartElement, (writer, BAD_CAST "string")); > + if (encoding) > + XML_CHECK (xmlTextWriterWriteAttribute, (writer, BAD_CAST > "encoding", BAD_CAST encoding)); > +} > + > +static void > +end_string(xmlTextWriterPtr writer) > +{ > + XML_CHECK (xmlTextWriterEndEl...
2011 Aug 13
2
[Hivex] [PATCH v3] Report last-modified time of hive root and nodes
...do { \ if ((proc args) == -1) { \ @@ -124,6 +126,20 @@ main (int argc, char *argv[]) XML_CHECK (xmlTextWriterStartDocument, (writer, NULL, "utf-8", NULL)); XML_CHECK (xmlTextWriterStartElement, (writer, BAD_CAST "hive")); + int64_t hive_mtime = hivex_last_modified (h); + if (hive_mtime < 0) + goto skip_mtime; + char *timebuf = filetime_to_8601 (hive_mtime); + if (timebuf == NULL) + goto skip_mtime; + XML_CHECK (xmlTextWriterStartElement, (writer, BAD_CAST "...
2017 Oct 05
2
[PATCH] inspector: Fix virt-inspector on *BSD guests (RHBZ#1144138).
...git a/inspector/inspector.c b/inspector/inspector.c index 3583c61df..30d279987 100644 --- a/inspector/inspector.c +++ b/inspector/inspector.c @@ -347,6 +347,7 @@ output_root (xmlTextWriterPtr xo, char *root) char buf[32]; char *canonical_root; size_t size; + int is_bsd; XMLERROR (-1, xmlTextWriterStartElement (xo, BAD_CAST "operatingsystem")); @@ -362,6 +363,10 @@ output_root (xmlTextWriterPtr xo, char *root) if (STRNEQ (str, "unknown")) XMLERROR (-1, xmlTextWriterWriteElement (xo, BAD_CAST "name", BAD_CAST str)); + is_bsd = + STREQ (str, "freebsd...
2018 Oct 04
0
[PATCH v2 2/4] common/utils: Move libxml2 writer macros to a common header file.
...XML2_WRITER_MACROS_H_ + +#include <stdarg.h> + +/** + * To define an XML element use: + * + * start_element ("name") { + * ... + * } end_element (); + * + * which produces C<<< <name>...</name> >>> + */ +#define start_element(element) \ + if (xmlTextWriterStartElement (xo, BAD_CAST (element)) == -1) { \ + xml_error ("xmlTextWriterStartElement"); \ + } \ + do + +#define end_element() \ + while (0); \ + do { \ + if (xmlTextWriterEndElement (xo) == -1) { \ + xml_error ("xmlTextWriterEndElement"); \ + }...
2012 Oct 08
3
[PATCH v3 0/3] Add support for disk labels and hotplugging.
This is, I guess, version 3 of this patch series which adds disk labels and hotplugging (only hot-add implemented so far). The good news is .. it works! Rich.
2013 Mar 15
0
[PATCH] lib: Add direct support for the NBD (Network Block Device) protocol.
...* a device or a file. For devices, use: - * <disk type=block device=disk> - * <source dev=[path]> - * For files, use: - * <disk type=file device=disk> - * <source file=[path]> - */ - is_host_device = is_blk (drv_priv->path); - XMLERROR (-1, xmlTextWriterStartElement (xo, BAD_CAST "disk")); XMLERROR (-1, xmlTextWriterWriteAttribute (xo, BAD_CAST "device", BAD_CAST "disk")); - if (!is_host_device) { - XMLERROR (-1, - xmlTextWriterWriteAttribute (xo, BAD_CAST...
2016 Mar 07
0
[PATCH] inspector: add --no-applications and --no-icon
...ns in the base distro. + */ + str = guestfs_inspect_get_icon (g, root, &size, + GUESTFS_INSPECT_GET_ICON_FAVICON, 0, + -1); + if (!str) exit (EXIT_FAILURE); + if (size > 0) { + XMLERROR (-1, xmlTextWriterStartElement (xo, BAD_CAST "icon")); + XMLERROR (-1, xmlTextWriterWriteBase64 (xo, str, 0, size)); + XMLERROR (-1, xmlTextWriterEndElement (xo)); + } + /* Note we must free (str) even if size == 0, because that indicates + * there was no icon. + */ + free (str)...
2011 Aug 31
1
[PATCH] hivex: Add byte runs for nodes and values
...+ size_t node_struct_length = hivex_node_struct_length (h, node); + if (errno) { + if (errno == EINVAL) { + fprintf (stderr, "node_byte_runs: Invoked on what does not seem to be a node (%zu).\n", node); + } + return -1; + } + /* A node has one byte run. */ + XML_CHECK (xmlTextWriterStartElement, (writer, BAD_CAST "byte_runs")); + XML_CHECK (xmlTextWriterStartElement, (writer, BAD_CAST "byte_run")); + memset (buf, 0, 1+BYTE_RUN_BUF_LEN); + snprintf (buf, 1+BYTE_RUN_BUF_LEN, "%d", node); + XML_CHECK (xmlTextWriterWriteAttribute, (writer, BAD_CAST "offs...
2012 Oct 08
5
[PATCH v4 0/5] Finish hotplugging support.
This rounds off hotplugging support by allowing you to add and remove drives at any stage (before and after launch). Rich.