2 * collectd - src/virt.c
3 * Copyright (C) 2006-2008 Red Hat Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; only version 2 of the license is applicable.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Richard W.M. Jones <rjones@redhat.com>
26 #include "utils_ignorelist.h"
27 #include "utils_complain.h"
29 #include <libvirt/libvirt.h>
30 #include <libvirt/virterror.h>
31 #include <libxml/parser.h>
32 #include <libxml/tree.h>
33 #include <libxml/xpath.h>
38 #define PLUGIN_NAME "virt"
40 static const char *config_keys[] = {
48 "BlockDeviceFormatBasename",
55 "PluginInstanceFormat",
59 #define NR_CONFIG_KEYS ((sizeof config_keys / sizeof config_keys[0]) - 1)
62 static virConnectPtr conn = 0;
63 static char *conn_string = NULL;
64 static c_complain_t conn_complain = C_COMPLAIN_INIT_STATIC;
66 /* Seconds between list refreshes, 0 disables completely. */
67 static int interval = 60;
69 /* List of domains, if specified. */
70 static ignorelist_t *il_domains = NULL;
71 /* List of block devices, if specified. */
72 static ignorelist_t *il_block_devices = NULL;
73 /* List of network interface devices, if specified. */
74 static ignorelist_t *il_interface_devices = NULL;
76 static int ignore_device_match (ignorelist_t *,
77 const char *domname, const char *devpath);
79 /* Actual list of domains found on last refresh. */
80 static virDomainPtr *domains = NULL;
81 static int nr_domains = 0;
83 static void free_domains (void);
84 static int add_domain (virDomainPtr dom);
86 /* Actual list of block devices found on last refresh. */
88 virDomainPtr dom; /* domain */
89 char *path; /* name of block device */
92 static struct block_device *block_devices = NULL;
93 static int nr_block_devices = 0;
95 static void free_block_devices (void);
96 static int add_block_device (virDomainPtr dom, const char *path);
98 /* Actual list of network interfaces found on last refresh. */
99 struct interface_device {
100 virDomainPtr dom; /* domain */
101 char *path; /* name of interface device */
102 char *address; /* mac address of interface device */
103 char *number; /* interface device number */
106 static struct interface_device *interface_devices = NULL;
107 static int nr_interface_devices = 0;
109 static void free_interface_devices (void);
110 static int add_interface_device (virDomainPtr dom, const char *path, const char *address, unsigned int number);
112 /* HostnameFormat. */
113 #define HF_MAX_FIELDS 3
122 static enum hf_field hostname_format[HF_MAX_FIELDS] =
125 /* PluginInstanceFormat */
126 #define PLGINST_MAX_FIELDS 2
134 static enum plginst_field plugin_instance_format[PLGINST_MAX_FIELDS] =
137 /* BlockDeviceFormat */
143 /* InterfaceFormat. */
150 /* BlockDeviceFormatBasename */
151 _Bool blockdevice_format_basename = false;
152 static enum bd_field blockdevice_format = target;
153 static enum if_field interface_format = if_name;
155 /* Time that we last refreshed. */
156 static time_t last_refresh = (time_t) 0;
158 static int refresh_lists (void);
160 /* ERROR(...) macro for virterrors. */
161 #define VIRT_ERROR(conn,s) do { \
163 err = (conn) ? virConnGetLastError ((conn)) : virGetLastError (); \
164 if (err) ERROR ("%s: %s", (s), err->message); \
168 init_value_list (value_list_t *vl, virDomainPtr dom)
172 char uuid[VIR_UUID_STRING_BUFLEN];
174 sstrncpy (vl->plugin, PLUGIN_NAME, sizeof (vl->plugin));
178 /* Construct the hostname field according to HostnameFormat. */
179 for (int i = 0; i < HF_MAX_FIELDS; ++i) {
180 if (hostname_format[i] == hf_none)
183 n = DATA_MAX_NAME_LEN - strlen (vl->host) - 2;
185 if (i > 0 && n >= 1) {
186 strncat (vl->host, ":", 1);
190 switch (hostname_format[i]) {
193 strncat (vl->host, hostname_g, n);
196 name = virDomainGetName (dom);
198 strncat (vl->host, name, n);
201 if (virDomainGetUUIDString (dom, uuid) == 0)
202 strncat (vl->host, uuid, n);
207 vl->host[sizeof (vl->host) - 1] = '\0';
209 /* Construct the plugin instance field according to PluginInstanceFormat. */
210 for (int i = 0; i < PLGINST_MAX_FIELDS; ++i) {
211 if (plugin_instance_format[i] == plginst_none)
214 n = sizeof(vl->plugin_instance) - strlen (vl->plugin_instance) - 2;
216 if (i > 0 && n >= 1) {
217 strncat (vl->plugin_instance, ":", 1);
221 switch (plugin_instance_format[i]) {
222 case plginst_none: break;
224 name = virDomainGetName (dom);
226 strncat (vl->plugin_instance, name, n);
229 if (virDomainGetUUIDString (dom, uuid) == 0)
230 strncat (vl->plugin_instance, uuid, n);
235 vl->plugin_instance[sizeof (vl->plugin_instance) - 1] = '\0';
237 } /* void init_value_list */
239 static void submit (virDomainPtr dom,
240 char const *type, char const *type_instance,
241 value_t *values, size_t values_len)
243 value_list_t vl = VALUE_LIST_INIT;
244 init_value_list (&vl, dom);
247 vl.values_len = values_len;
249 sstrncpy (vl.type, type, sizeof (vl.type));
250 if (type_instance != NULL)
251 sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
253 plugin_dispatch_values (&vl);
257 memory_submit (gauge_t value, virDomainPtr dom)
259 submit (dom, "memory", "total", &(value_t) { .gauge = value }, 1);
263 memory_stats_submit (gauge_t value, virDomainPtr dom, int tag_index)
265 static const char *tags[] = { "swap_in", "swap_out", "major_fault", "minor_fault",
266 "unused", "available", "actual_balloon", "rss"};
268 if ((tag_index < 0) || (tag_index >= STATIC_ARRAY_SIZE (tags))) {
269 ERROR ("virt plugin: Array index out of bounds: tag_index = %d", tag_index);
273 submit (dom, "memory", tags[tag_index], &(value_t) { .gauge = value }, 1);
277 cpu_submit (unsigned long long value,
278 virDomainPtr dom, const char *type)
280 submit (dom, type, NULL, &(value_t) { .derive = (derive_t) value }, 1);
284 vcpu_submit (derive_t value,
285 virDomainPtr dom, int vcpu_nr, const char *type)
287 char type_instance[DATA_MAX_NAME_LEN];
289 ssnprintf (type_instance, sizeof (type_instance), "%d", vcpu_nr);
291 submit (dom, type, type_instance, &(value_t) { .derive = value }, 1);
295 submit_derive2 (const char *type, derive_t v0, derive_t v1,
296 virDomainPtr dom, const char *devname)
303 submit (dom, type, devname, values, STATIC_ARRAY_SIZE (values));
304 } /* void submit_derive2 */
309 if (virInitialize () != 0)
316 lv_config (const char *key, const char *value)
318 if (virInitialize () != 0)
321 if (il_domains == NULL)
322 il_domains = ignorelist_create (1);
323 if (il_block_devices == NULL)
324 il_block_devices = ignorelist_create (1);
325 if (il_interface_devices == NULL)
326 il_interface_devices = ignorelist_create (1);
328 if (strcasecmp (key, "Connection") == 0) {
329 char *tmp = strdup (value);
331 ERROR (PLUGIN_NAME " plugin: Connection strdup failed.");
339 if (strcasecmp (key, "RefreshInterval") == 0) {
341 interval = strtol (value, &eptr, 10);
342 if (eptr == NULL || *eptr != '\0') return 1;
346 if (strcasecmp (key, "Domain") == 0) {
347 if (ignorelist_add (il_domains, value)) return 1;
350 if (strcasecmp (key, "BlockDevice") == 0) {
351 if (ignorelist_add (il_block_devices, value)) return 1;
355 if (strcasecmp (key, "BlockDeviceFormat") == 0) {
356 if (strcasecmp (value, "target") == 0)
357 blockdevice_format = target;
358 else if (strcasecmp (value, "source") == 0)
359 blockdevice_format = source;
361 ERROR (PLUGIN_NAME " plugin: unknown BlockDeviceFormat: %s", value);
366 if (strcasecmp (key, "BlockDeviceFormatBasename") == 0) {
367 if (strcasecmp (value, "true") == 0)
368 blockdevice_format_basename = true;
369 else if (strcasecmp (value, "false") == 0)
370 blockdevice_format_basename = false;
372 ERROR (PLUGIN_NAME " plugin: unknown BlockDeviceFormatBasename: %s", value);
377 if (strcasecmp (key, "InterfaceDevice") == 0) {
378 if (ignorelist_add (il_interface_devices, value)) return 1;
382 if (strcasecmp (key, "IgnoreSelected") == 0) {
385 ignorelist_set_invert (il_domains, 0);
386 ignorelist_set_invert (il_block_devices, 0);
387 ignorelist_set_invert (il_interface_devices, 0);
391 ignorelist_set_invert (il_domains, 1);
392 ignorelist_set_invert (il_block_devices, 1);
393 ignorelist_set_invert (il_interface_devices, 1);
398 if (strcasecmp (key, "HostnameFormat") == 0) {
400 char *fields[HF_MAX_FIELDS];
403 value_copy = strdup (value);
404 if (value_copy == NULL) {
405 ERROR (PLUGIN_NAME " plugin: strdup failed.");
409 n = strsplit (value_copy, fields, HF_MAX_FIELDS);
412 ERROR (PLUGIN_NAME " plugin: HostnameFormat: no fields");
416 for (int i = 0; i < n; ++i) {
417 if (strcasecmp (fields[i], "hostname") == 0)
418 hostname_format[i] = hf_hostname;
419 else if (strcasecmp (fields[i], "name") == 0)
420 hostname_format[i] = hf_name;
421 else if (strcasecmp (fields[i], "uuid") == 0)
422 hostname_format[i] = hf_uuid;
424 ERROR (PLUGIN_NAME " plugin: unknown HostnameFormat field: %s", fields[i]);
431 for (int i = n; i < HF_MAX_FIELDS; ++i)
432 hostname_format[i] = hf_none;
437 if (strcasecmp (key, "PluginInstanceFormat") == 0) {
439 char *fields[PLGINST_MAX_FIELDS];
442 value_copy = strdup (value);
443 if (value_copy == NULL) {
444 ERROR (PLUGIN_NAME " plugin: strdup failed.");
448 n = strsplit (value_copy, fields, PLGINST_MAX_FIELDS);
451 ERROR (PLUGIN_NAME " plugin: PluginInstanceFormat: no fields");
455 for (int i = 0; i < n; ++i) {
456 if (strcasecmp (fields[i], "none") == 0) {
457 plugin_instance_format[i] = plginst_none;
459 } else if (strcasecmp (fields[i], "name") == 0)
460 plugin_instance_format[i] = plginst_name;
461 else if (strcasecmp (fields[i], "uuid") == 0)
462 plugin_instance_format[i] = plginst_uuid;
464 ERROR (PLUGIN_NAME " plugin: unknown PluginInstanceFormat field: %s", fields[i]);
471 for (int i = n; i < PLGINST_MAX_FIELDS; ++i)
472 plugin_instance_format[i] = plginst_none;
477 if (strcasecmp (key, "InterfaceFormat") == 0) {
478 if (strcasecmp (value, "name") == 0)
479 interface_format = if_name;
480 else if (strcasecmp (value, "address") == 0)
481 interface_format = if_address;
482 else if (strcasecmp (value, "number") == 0)
483 interface_format = if_number;
485 ERROR (PLUGIN_NAME " plugin: unknown InterfaceFormat: %s", value);
491 /* Unrecognised option. */
501 /* `conn_string == NULL' is acceptable. */
502 conn = virConnectOpenReadOnly (conn_string);
504 c_complain (LOG_ERR, &conn_complain,
505 PLUGIN_NAME " plugin: Unable to connect: "
506 "virConnectOpenReadOnly failed.");
510 c_release (LOG_NOTICE, &conn_complain,
511 PLUGIN_NAME " plugin: Connection established.");
515 /* Need to refresh domain or device lists? */
516 if ((last_refresh == (time_t) 0) ||
517 ((interval > 0) && ((last_refresh + interval) <= t))) {
518 if (refresh_lists () != 0) {
520 virConnectClose (conn);
528 for (int i = 0; i < nr_domains; ++i)
529 fprintf (stderr, "domain %s\n", virDomainGetName (domains[i]));
530 for (int i = 0; i < nr_block_devices; ++i)
531 fprintf (stderr, "block device %d %s:%s\n",
532 i, virDomainGetName (block_devices[i].dom),
533 block_devices[i].path);
534 for (int i = 0; i < nr_interface_devices; ++i)
535 fprintf (stderr, "interface device %d %s:%s\n",
536 i, virDomainGetName (interface_devices[i].dom),
537 interface_devices[i].path);
540 /* Get CPU usage, memory, VCPU usage for each domain. */
541 for (int i = 0; i < nr_domains; ++i) {
543 virVcpuInfoPtr vinfo = NULL;
544 virDomainMemoryStatPtr minfo = NULL;
547 status = virDomainGetInfo (domains[i], &info);
550 ERROR (PLUGIN_NAME " plugin: virDomainGetInfo failed with status %i.",
555 if (info.state != VIR_DOMAIN_RUNNING)
557 /* only gather stats for running domains */
561 cpu_submit (info.cpuTime, domains[i], "virt_cpu_total");
562 memory_submit ((gauge_t) info.memory * 1024, domains[i]);
564 vinfo = malloc (info.nrVirtCpu * sizeof (vinfo[0]));
566 ERROR (PLUGIN_NAME " plugin: malloc failed.");
570 status = virDomainGetVcpus (domains[i], vinfo, info.nrVirtCpu,
571 /* cpu map = */ NULL, /* cpu map length = */ 0);
574 ERROR (PLUGIN_NAME " plugin: virDomainGetVcpus failed with status %i.",
580 for (int j = 0; j < info.nrVirtCpu; ++j)
581 vcpu_submit (vinfo[j].cpuTime,
582 domains[i], vinfo[j].number, "virt_vcpu");
586 minfo = malloc (VIR_DOMAIN_MEMORY_STAT_NR * sizeof (virDomainMemoryStatStruct));
588 ERROR ("virt plugin: malloc failed.");
592 status = virDomainMemoryStats (domains[i], minfo, VIR_DOMAIN_MEMORY_STAT_NR, 0);
595 ERROR ("virt plugin: virDomainMemoryStats failed with status %i.",
601 for (int j = 0; j < status; j++) {
602 memory_stats_submit ((gauge_t) minfo[j].val * 1024, domains[i], minfo[j].tag);
609 /* Get block device stats for each domain. */
610 for (int i = 0; i < nr_block_devices; ++i) {
611 struct _virDomainBlockStats stats;
613 if (virDomainBlockStats (block_devices[i].dom, block_devices[i].path,
614 &stats, sizeof stats) != 0)
617 char *type_instance = NULL;
618 if( blockdevice_format_basename && blockdevice_format == source ) //valid only if we use "source" (full path to the device)
620 type_instance = strdup(basename(block_devices[i].path));
624 type_instance = strdup(block_devices[i].path);
626 if ((stats.rd_req != -1) && (stats.wr_req != -1))
627 submit_derive2 ("disk_ops",
628 (derive_t) stats.rd_req, (derive_t) stats.wr_req,
629 block_devices[i].dom, type_instance);
631 if ((stats.rd_bytes != -1) && (stats.wr_bytes != -1))
632 submit_derive2 ("disk_octets",
633 (derive_t) stats.rd_bytes, (derive_t) stats.wr_bytes,
634 block_devices[i].dom, type_instance);
636 sfree(type_instance);
637 } /* for (nr_block_devices) */
639 /* Get interface stats for each domain. */
640 for (int i = 0; i < nr_interface_devices; ++i) {
641 struct _virDomainInterfaceStats stats;
642 char *display_name = NULL;
645 switch (interface_format) {
647 display_name = interface_devices[i].address;
650 display_name = interface_devices[i].number;
654 display_name = interface_devices[i].path;
657 if (virDomainInterfaceStats (interface_devices[i].dom,
658 interface_devices[i].path,
659 &stats, sizeof stats) != 0)
662 if ((stats.rx_bytes != -1) && (stats.tx_bytes != -1))
663 submit_derive2 ("if_octets",
664 (derive_t) stats.rx_bytes, (derive_t) stats.tx_bytes,
665 interface_devices[i].dom, display_name);
667 if ((stats.rx_packets != -1) && (stats.tx_packets != -1))
668 submit_derive2 ("if_packets",
669 (derive_t) stats.rx_packets, (derive_t) stats.tx_packets,
670 interface_devices[i].dom, display_name);
672 if ((stats.rx_errs != -1) && (stats.tx_errs != -1))
673 submit_derive2 ("if_errors",
674 (derive_t) stats.rx_errs, (derive_t) stats.tx_errs,
675 interface_devices[i].dom, display_name);
677 if ((stats.rx_drop != -1) && (stats.tx_drop != -1))
678 submit_derive2 ("if_dropped",
679 (derive_t) stats.rx_drop, (derive_t) stats.tx_drop,
680 interface_devices[i].dom, display_name);
681 } /* for (nr_interface_devices) */
691 n = virConnectNumOfDomains (conn);
693 VIRT_ERROR (conn, "reading number of domains");
700 /* Get list of domains. */
701 domids = malloc (sizeof (*domids) * n);
702 if (domids == NULL) {
703 ERROR (PLUGIN_NAME " plugin: malloc failed.");
707 n = virConnectListDomains (conn, domids, n);
709 VIRT_ERROR (conn, "reading list of domains");
714 free_block_devices ();
715 free_interface_devices ();
718 /* Fetch each domain and add it to the list, unless ignore. */
719 for (int i = 0; i < n; ++i) {
720 virDomainPtr dom = NULL;
723 xmlDocPtr xml_doc = NULL;
724 xmlXPathContextPtr xpath_ctx = NULL;
725 xmlXPathObjectPtr xpath_obj = NULL;
727 dom = virDomainLookupByID (conn, domids[i]);
729 VIRT_ERROR (conn, "virDomainLookupByID");
730 /* Could be that the domain went away -- ignore it anyway. */
734 name = virDomainGetName (dom);
736 VIRT_ERROR (conn, "virDomainGetName");
740 if (il_domains && ignorelist_match (il_domains, name) != 0)
743 if (add_domain (dom) < 0) {
744 ERROR (PLUGIN_NAME " plugin: malloc failed.");
748 /* Get a list of devices for this domain. */
749 xml = virDomainGetXMLDesc (dom, 0);
751 VIRT_ERROR (conn, "virDomainGetXMLDesc");
755 /* Yuck, XML. Parse out the devices. */
756 xml_doc = xmlReadDoc ((xmlChar *) xml, NULL, NULL, XML_PARSE_NONET);
757 if (xml_doc == NULL) {
758 VIRT_ERROR (conn, "xmlReadDoc");
762 xpath_ctx = xmlXPathNewContext (xml_doc);
765 char * bd_xmlpath = "/domain/devices/disk/target[@dev]"; //the default behavior
766 if( blockdevice_format == source )
768 bd_xmlpath = "/domain/devices/disk/source[@dev]";
770 xpath_obj = xmlXPathEval ((xmlChar *) bd_xmlpath, xpath_ctx);
772 if (xpath_obj == NULL || xpath_obj->type != XPATH_NODESET ||
773 xpath_obj->nodesetval == NULL)
776 for (int j = 0; j < xpath_obj->nodesetval->nodeNr; ++j) {
780 node = xpath_obj->nodesetval->nodeTab[j];
782 path = (char *) xmlGetProp (node, (xmlChar *) "dev");
785 if (il_block_devices &&
786 ignore_device_match (il_block_devices, name, path) != 0)
789 add_block_device (dom, path);
791 if (path) xmlFree (path);
793 xmlXPathFreeObject (xpath_obj);
795 /* Network interfaces. */
796 xpath_obj = xmlXPathEval
797 ((xmlChar *) "/domain/devices/interface[target[@dev]]",
799 if (xpath_obj == NULL || xpath_obj->type != XPATH_NODESET ||
800 xpath_obj->nodesetval == NULL)
803 xmlNodeSetPtr xml_interfaces = xpath_obj->nodesetval;
805 for (int j = 0; j < xml_interfaces->nodeNr; ++j) {
807 char *address = NULL;
808 xmlNodePtr xml_interface;
810 xml_interface = xml_interfaces->nodeTab[j];
811 if (!xml_interface) continue;
813 for (xmlNodePtr child = xml_interface->children; child; child = child->next) {
814 if (child->type != XML_ELEMENT_NODE) continue;
816 if (xmlStrEqual(child->name, (const xmlChar *) "target")) {
817 path = (char *) xmlGetProp (child, (const xmlChar *) "dev");
819 } else if (xmlStrEqual(child->name, (const xmlChar *) "mac")) {
820 address = (char *) xmlGetProp (child, (const xmlChar *) "address");
821 if (!address) continue;
825 if (il_interface_devices &&
826 (ignore_device_match (il_interface_devices, name, path) != 0 ||
827 ignore_device_match (il_interface_devices, name, address) != 0))
830 add_interface_device (dom, path, address, j+1);
832 if (path) xmlFree (path);
833 if (address) xmlFree (address);
837 if (xpath_obj) xmlXPathFreeObject (xpath_obj);
838 if (xpath_ctx) xmlXPathFreeContext (xpath_ctx);
839 if (xml_doc) xmlFreeDoc (xml_doc);
853 for (int i = 0; i < nr_domains; ++i)
854 virDomainFree (domains[i]);
862 add_domain (virDomainPtr dom)
864 virDomainPtr *new_ptr;
865 int new_size = sizeof (domains[0]) * (nr_domains+1);
868 new_ptr = realloc (domains, new_size);
870 new_ptr = malloc (new_size);
876 domains[nr_domains] = dom;
881 free_block_devices (void)
884 for (int i = 0; i < nr_block_devices; ++i)
885 sfree (block_devices[i].path);
886 sfree (block_devices);
888 block_devices = NULL;
889 nr_block_devices = 0;
893 add_block_device (virDomainPtr dom, const char *path)
895 struct block_device *new_ptr;
896 int new_size = sizeof (block_devices[0]) * (nr_block_devices+1);
899 path_copy = strdup (path);
904 new_ptr = realloc (block_devices, new_size);
906 new_ptr = malloc (new_size);
908 if (new_ptr == NULL) {
912 block_devices = new_ptr;
913 block_devices[nr_block_devices].dom = dom;
914 block_devices[nr_block_devices].path = path_copy;
915 return nr_block_devices++;
919 free_interface_devices (void)
921 if (interface_devices) {
922 for (int i = 0; i < nr_interface_devices; ++i) {
923 sfree (interface_devices[i].path);
924 sfree (interface_devices[i].address);
925 sfree (interface_devices[i].number);
927 sfree (interface_devices);
929 interface_devices = NULL;
930 nr_interface_devices = 0;
934 add_interface_device (virDomainPtr dom, const char *path, const char *address, unsigned int number)
936 struct interface_device *new_ptr;
937 int new_size = sizeof (interface_devices[0]) * (nr_interface_devices+1);
938 char *path_copy, *address_copy, number_string[15];
940 if ((path == NULL) || (address == NULL))
943 path_copy = strdup (path);
944 if (!path_copy) return -1;
946 address_copy = strdup (address);
952 snprintf(number_string, sizeof (number_string), "interface-%u", number);
954 if (interface_devices)
955 new_ptr = realloc (interface_devices, new_size);
957 new_ptr = malloc (new_size);
959 if (new_ptr == NULL) {
961 sfree (address_copy);
964 interface_devices = new_ptr;
965 interface_devices[nr_interface_devices].dom = dom;
966 interface_devices[nr_interface_devices].path = path_copy;
967 interface_devices[nr_interface_devices].address = address_copy;
968 interface_devices[nr_interface_devices].number = strdup(number_string);
969 return nr_interface_devices++;
973 ignore_device_match (ignorelist_t *il, const char *domname, const char *devpath)
978 if ((domname == NULL) || (devpath == NULL))
981 n = sizeof (char) * (strlen (domname) + strlen (devpath) + 2);
984 ERROR (PLUGIN_NAME " plugin: malloc failed.");
987 ssnprintf (name, n, "%s:%s", domname, devpath);
988 r = ignorelist_match (il, name);
996 free_block_devices ();
997 free_interface_devices ();
1001 virConnectClose (conn);
1004 ignorelist_free (il_domains);
1006 ignorelist_free (il_block_devices);
1007 il_block_devices = NULL;
1008 ignorelist_free (il_interface_devices);
1009 il_interface_devices = NULL;
1015 module_register (void)
1017 plugin_register_config (PLUGIN_NAME,
1019 config_keys, NR_CONFIG_KEYS);
1020 plugin_register_init (PLUGIN_NAME, lv_init);
1021 plugin_register_read (PLUGIN_NAME, lv_read);
1022 plugin_register_shutdown (PLUGIN_NAME, lv_shutdown);
1026 * vim: shiftwidth=4 tabstop=8 softtabstop=4 expandtab fdm=marker