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>
37 #define PLUGIN_NAME "virt"
39 static const char *config_keys[] = {
47 "BlockDeviceFormatBasename",
54 "PluginInstanceFormat",
58 #define NR_CONFIG_KEYS ((sizeof config_keys / sizeof config_keys[0]) - 1)
61 static virConnectPtr conn = 0;
62 static char *conn_string = NULL;
63 static c_complain_t conn_complain = C_COMPLAIN_INIT_STATIC;
65 /* Seconds between list refreshes, 0 disables completely. */
66 static int interval = 60;
68 /* List of domains, if specified. */
69 static ignorelist_t *il_domains = NULL;
70 /* List of block devices, if specified. */
71 static ignorelist_t *il_block_devices = NULL;
72 /* List of network interface devices, if specified. */
73 static ignorelist_t *il_interface_devices = NULL;
75 static int ignore_device_match (ignorelist_t *,
76 const char *domname, const char *devpath);
78 /* Actual list of domains found on last refresh. */
79 static virDomainPtr *domains = NULL;
80 static int nr_domains = 0;
82 static void free_domains (void);
83 static int add_domain (virDomainPtr dom);
85 /* Actual list of block devices found on last refresh. */
87 virDomainPtr dom; /* domain */
88 char *path; /* name of block device */
91 static struct block_device *block_devices = NULL;
92 static int nr_block_devices = 0;
94 static void free_block_devices (void);
95 static int add_block_device (virDomainPtr dom, const char *path);
97 /* Actual list of network interfaces found on last refresh. */
98 struct interface_device {
99 virDomainPtr dom; /* domain */
100 char *path; /* name of interface device */
101 char *address; /* mac address of interface device */
102 char *number; /* interface device number */
105 static struct interface_device *interface_devices = NULL;
106 static int nr_interface_devices = 0;
108 static void free_interface_devices (void);
109 static int add_interface_device (virDomainPtr dom, const char *path, const char *address, unsigned int number);
111 /* HostnameFormat. */
112 #define HF_MAX_FIELDS 3
121 static enum hf_field hostname_format[HF_MAX_FIELDS] =
124 /* PluginInstanceFormat */
125 #define PLGINST_MAX_FIELDS 2
133 static enum plginst_field plugin_instance_format[PLGINST_MAX_FIELDS] =
136 /* BlockDeviceFormat */
142 /* InterfaceFormat. */
149 /* BlockDeviceFormatBasename */
150 char *blockdevice_format_basename="false";
151 static enum bd_field blockdevice_format = dev;
152 static enum if_field interface_format = if_name;
154 /* Time that we last refreshed. */
155 static time_t last_refresh = (time_t) 0;
157 static int refresh_lists (void);
159 /* ERROR(...) macro for virterrors. */
160 #define VIRT_ERROR(conn,s) do { \
162 err = (conn) ? virConnGetLastError ((conn)) : virGetLastError (); \
163 if (err) ERROR ("%s: %s", (s), err->message); \
167 init_value_list (value_list_t *vl, virDomainPtr dom)
171 char uuid[VIR_UUID_STRING_BUFLEN];
173 sstrncpy (vl->plugin, PLUGIN_NAME, sizeof (vl->plugin));
177 /* Construct the hostname field according to HostnameFormat. */
178 for (int i = 0; i < HF_MAX_FIELDS; ++i) {
179 if (hostname_format[i] == hf_none)
182 n = DATA_MAX_NAME_LEN - strlen (vl->host) - 2;
184 if (i > 0 && n >= 1) {
185 strncat (vl->host, ":", 1);
189 switch (hostname_format[i]) {
192 strncat (vl->host, hostname_g, n);
195 name = virDomainGetName (dom);
197 strncat (vl->host, name, n);
200 if (virDomainGetUUIDString (dom, uuid) == 0)
201 strncat (vl->host, uuid, n);
206 vl->host[sizeof (vl->host) - 1] = '\0';
208 /* Construct the plugin instance field according to PluginInstanceFormat. */
209 for (int i = 0; i < PLGINST_MAX_FIELDS; ++i) {
210 if (plugin_instance_format[i] == plginst_none)
213 n = sizeof(vl->plugin_instance) - strlen (vl->plugin_instance) - 2;
215 if (i > 0 && n >= 1) {
216 strncat (vl->plugin_instance, ":", 1);
220 switch (plugin_instance_format[i]) {
221 case plginst_none: break;
223 name = virDomainGetName (dom);
225 strncat (vl->plugin_instance, name, n);
228 if (virDomainGetUUIDString (dom, uuid) == 0)
229 strncat (vl->plugin_instance, uuid, n);
234 vl->plugin_instance[sizeof (vl->plugin_instance) - 1] = '\0';
236 } /* void init_value_list */
238 static void submit (virDomainPtr dom,
239 char const *type, char const *type_instance,
240 value_t *values, size_t values_len)
242 value_list_t vl = VALUE_LIST_INIT;
243 init_value_list (&vl, dom);
246 vl.values_len = values_len;
248 sstrncpy (vl.type, type, sizeof (vl.type));
249 if (type_instance != NULL)
250 sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
252 plugin_dispatch_values (&vl);
256 memory_submit (gauge_t value, virDomainPtr dom)
258 submit (dom, "memory", "total", &(value_t) { .gauge = value }, 1);
262 memory_stats_submit (gauge_t value, virDomainPtr dom, int tag_index)
264 static const char *tags[] = { "swap_in", "swap_out", "major_fault", "minor_fault",
265 "unused", "available", "actual_balloon", "rss"};
267 if ((tag_index < 0) || (tag_index >= STATIC_ARRAY_SIZE (tags))) {
268 ERROR ("virt plugin: Array index out of bounds: tag_index = %d", tag_index);
272 submit (dom, "memory", tags[tag_index], &(value_t) { .gauge = value }, 1);
276 cpu_submit (unsigned long long value,
277 virDomainPtr dom, const char *type)
279 submit (dom, type, NULL, &(value_t) { .derive = (derive_t) value }, 1);
283 vcpu_submit (derive_t value,
284 virDomainPtr dom, int vcpu_nr, const char *type)
286 char type_instance[DATA_MAX_NAME_LEN];
288 ssnprintf (type_instance, sizeof (type_instance), "%d", vcpu_nr);
290 submit (dom, type, type_instance, &(value_t) { .derive = value }, 1);
294 submit_derive2 (const char *type, derive_t v0, derive_t v1,
295 virDomainPtr dom, const char *devname)
302 submit (dom, type, devname, values, STATIC_ARRAY_SIZE (values));
303 } /* void submit_derive2 */
308 if (virInitialize () != 0)
315 lv_config (const char *key, const char *value)
317 if (virInitialize () != 0)
320 if (il_domains == NULL)
321 il_domains = ignorelist_create (1);
322 if (il_block_devices == NULL)
323 il_block_devices = ignorelist_create (1);
324 if (il_interface_devices == NULL)
325 il_interface_devices = ignorelist_create (1);
327 if (strcasecmp (key, "Connection") == 0) {
328 char *tmp = strdup (value);
330 ERROR (PLUGIN_NAME " plugin: Connection strdup failed.");
338 if (strcasecmp (key, "RefreshInterval") == 0) {
340 interval = strtol (value, &eptr, 10);
341 if (eptr == NULL || *eptr != '\0') return 1;
345 if (strcasecmp (key, "Domain") == 0) {
346 if (ignorelist_add (il_domains, value)) return 1;
349 if (strcasecmp (key, "BlockDevice") == 0) {
350 if (ignorelist_add (il_block_devices, value)) return 1;
354 if (strcasecmp (key, "BlockDeviceFormat") == 0) {
355 if (strcasecmp (value, "dev") == 0)
356 blockdevice_format = dev;
357 else if (strcasecmp (value, "source") == 0)
358 blockdevice_format = source;
360 ERROR (PLUGIN_NAME " plugin: unknown BlockDeviceFormat: %s", value);
365 if (strcasecmp (key, "BlockDeviceFormatBasename") == 0) {
366 if (strcasecmp (value, "true") == 0)
367 blockdevice_format_basename = "true";
368 else if (strcasecmp (value, "false") == 0)
369 blockdevice_format_basename = "false";
371 ERROR (PLUGIN_NAME " plugin: unknown BlockDeviceFormatBasename: %s", value);
376 if (strcasecmp (key, "InterfaceDevice") == 0) {
377 if (ignorelist_add (il_interface_devices, value)) return 1;
381 if (strcasecmp (key, "IgnoreSelected") == 0) {
384 ignorelist_set_invert (il_domains, 0);
385 ignorelist_set_invert (il_block_devices, 0);
386 ignorelist_set_invert (il_interface_devices, 0);
390 ignorelist_set_invert (il_domains, 1);
391 ignorelist_set_invert (il_block_devices, 1);
392 ignorelist_set_invert (il_interface_devices, 1);
397 if (strcasecmp (key, "HostnameFormat") == 0) {
399 char *fields[HF_MAX_FIELDS];
402 value_copy = strdup (value);
403 if (value_copy == NULL) {
404 ERROR (PLUGIN_NAME " plugin: strdup failed.");
408 n = strsplit (value_copy, fields, HF_MAX_FIELDS);
411 ERROR (PLUGIN_NAME " plugin: HostnameFormat: no fields");
415 for (int i = 0; i < n; ++i) {
416 if (strcasecmp (fields[i], "hostname") == 0)
417 hostname_format[i] = hf_hostname;
418 else if (strcasecmp (fields[i], "name") == 0)
419 hostname_format[i] = hf_name;
420 else if (strcasecmp (fields[i], "uuid") == 0)
421 hostname_format[i] = hf_uuid;
423 ERROR (PLUGIN_NAME " plugin: unknown HostnameFormat field: %s", fields[i]);
430 for (int i = n; i < HF_MAX_FIELDS; ++i)
431 hostname_format[i] = hf_none;
436 if (strcasecmp (key, "PluginInstanceFormat") == 0) {
438 char *fields[PLGINST_MAX_FIELDS];
441 value_copy = strdup (value);
442 if (value_copy == NULL) {
443 ERROR (PLUGIN_NAME " plugin: strdup failed.");
447 n = strsplit (value_copy, fields, PLGINST_MAX_FIELDS);
450 ERROR (PLUGIN_NAME " plugin: PluginInstanceFormat: no fields");
454 for (int i = 0; i < n; ++i) {
455 if (strcasecmp (fields[i], "none") == 0) {
456 plugin_instance_format[i] = plginst_none;
458 } else if (strcasecmp (fields[i], "name") == 0)
459 plugin_instance_format[i] = plginst_name;
460 else if (strcasecmp (fields[i], "uuid") == 0)
461 plugin_instance_format[i] = plginst_uuid;
463 ERROR (PLUGIN_NAME " plugin: unknown PluginInstanceFormat field: %s", fields[i]);
470 for (int i = n; i < PLGINST_MAX_FIELDS; ++i)
471 plugin_instance_format[i] = plginst_none;
476 if (strcasecmp (key, "InterfaceFormat") == 0) {
477 if (strcasecmp (value, "name") == 0)
478 interface_format = if_name;
479 else if (strcasecmp (value, "address") == 0)
480 interface_format = if_address;
481 else if (strcasecmp (value, "number") == 0)
482 interface_format = if_number;
484 ERROR (PLUGIN_NAME " plugin: unknown InterfaceFormat: %s", value);
490 /* Unrecognised option. */
500 /* `conn_string == NULL' is acceptable. */
501 conn = virConnectOpenReadOnly (conn_string);
503 c_complain (LOG_ERR, &conn_complain,
504 PLUGIN_NAME " plugin: Unable to connect: "
505 "virConnectOpenReadOnly failed.");
509 c_release (LOG_NOTICE, &conn_complain,
510 PLUGIN_NAME " plugin: Connection established.");
514 /* Need to refresh domain or device lists? */
515 if ((last_refresh == (time_t) 0) ||
516 ((interval > 0) && ((last_refresh + interval) <= t))) {
517 if (refresh_lists () != 0) {
519 virConnectClose (conn);
527 for (int i = 0; i < nr_domains; ++i)
528 fprintf (stderr, "domain %s\n", virDomainGetName (domains[i]));
529 for (int i = 0; i < nr_block_devices; ++i)
530 fprintf (stderr, "block device %d %s:%s\n",
531 i, virDomainGetName (block_devices[i].dom),
532 block_devices[i].path);
533 for (int i = 0; i < nr_interface_devices; ++i)
534 fprintf (stderr, "interface device %d %s:%s\n",
535 i, virDomainGetName (interface_devices[i].dom),
536 interface_devices[i].path);
539 /* Get CPU usage, memory, VCPU usage for each domain. */
540 for (int i = 0; i < nr_domains; ++i) {
542 virVcpuInfoPtr vinfo = NULL;
543 virDomainMemoryStatPtr minfo = NULL;
546 status = virDomainGetInfo (domains[i], &info);
549 ERROR (PLUGIN_NAME " plugin: virDomainGetInfo failed with status %i.",
554 if (info.state != VIR_DOMAIN_RUNNING)
556 /* only gather stats for running domains */
560 cpu_submit (info.cpuTime, domains[i], "virt_cpu_total");
561 memory_submit ((gauge_t) info.memory * 1024, domains[i]);
563 vinfo = malloc (info.nrVirtCpu * sizeof (vinfo[0]));
565 ERROR (PLUGIN_NAME " plugin: malloc failed.");
569 status = virDomainGetVcpus (domains[i], vinfo, info.nrVirtCpu,
570 /* cpu map = */ NULL, /* cpu map length = */ 0);
573 ERROR (PLUGIN_NAME " plugin: virDomainGetVcpus failed with status %i.",
579 for (int j = 0; j < info.nrVirtCpu; ++j)
580 vcpu_submit (vinfo[j].cpuTime,
581 domains[i], vinfo[j].number, "virt_vcpu");
585 minfo = malloc (VIR_DOMAIN_MEMORY_STAT_NR * sizeof (virDomainMemoryStatStruct));
587 ERROR ("virt plugin: malloc failed.");
591 status = virDomainMemoryStats (domains[i], minfo, VIR_DOMAIN_MEMORY_STAT_NR, 0);
594 ERROR ("virt plugin: virDomainMemoryStats failed with status %i.",
600 for (int j = 0; j < status; j++) {
601 memory_stats_submit ((gauge_t) minfo[j].val * 1024, domains[i], minfo[j].tag);
608 /* Get block device stats for each domain. */
609 for (int i = 0; i < nr_block_devices; ++i) {
610 struct _virDomainBlockStats stats;
612 if (virDomainBlockStats (block_devices[i].dom, block_devices[i].path,
613 &stats, sizeof stats) != 0)
617 if( 0==strcasecmp("true", blockdevice_format_basename) && source==blockdevice_format){ //valid only if we use source (full path to the device)
618 new_path=strdup(basename(block_devices[i].path));
620 new_path=strdup(block_devices[i].path);
622 if ((stats.rd_req != -1) && (stats.wr_req != -1))
623 submit_derive2 ("disk_ops",
624 (derive_t) stats.rd_req, (derive_t) stats.wr_req,
625 block_devices[i].dom, new_path);
627 if ((stats.rd_bytes != -1) && (stats.wr_bytes != -1))
628 submit_derive2 ("disk_octets",
629 (derive_t) stats.rd_bytes, (derive_t) stats.wr_bytes,
630 block_devices[i].dom, new_path);
633 } /* for (nr_block_devices) */
635 /* Get interface stats for each domain. */
636 for (int i = 0; i < nr_interface_devices; ++i) {
637 struct _virDomainInterfaceStats stats;
638 char *display_name = NULL;
641 switch (interface_format) {
643 display_name = interface_devices[i].address;
646 display_name = interface_devices[i].number;
650 display_name = interface_devices[i].path;
653 if (virDomainInterfaceStats (interface_devices[i].dom,
654 interface_devices[i].path,
655 &stats, sizeof stats) != 0)
658 if ((stats.rx_bytes != -1) && (stats.tx_bytes != -1))
659 submit_derive2 ("if_octets",
660 (derive_t) stats.rx_bytes, (derive_t) stats.tx_bytes,
661 interface_devices[i].dom, display_name);
663 if ((stats.rx_packets != -1) && (stats.tx_packets != -1))
664 submit_derive2 ("if_packets",
665 (derive_t) stats.rx_packets, (derive_t) stats.tx_packets,
666 interface_devices[i].dom, display_name);
668 if ((stats.rx_errs != -1) && (stats.tx_errs != -1))
669 submit_derive2 ("if_errors",
670 (derive_t) stats.rx_errs, (derive_t) stats.tx_errs,
671 interface_devices[i].dom, display_name);
673 if ((stats.rx_drop != -1) && (stats.tx_drop != -1))
674 submit_derive2 ("if_dropped",
675 (derive_t) stats.rx_drop, (derive_t) stats.tx_drop,
676 interface_devices[i].dom, display_name);
677 } /* for (nr_interface_devices) */
687 n = virConnectNumOfDomains (conn);
689 VIRT_ERROR (conn, "reading number of domains");
696 /* Get list of domains. */
697 domids = malloc (sizeof (*domids) * n);
698 if (domids == NULL) {
699 ERROR (PLUGIN_NAME " plugin: malloc failed.");
703 n = virConnectListDomains (conn, domids, n);
705 VIRT_ERROR (conn, "reading list of domains");
710 free_block_devices ();
711 free_interface_devices ();
714 /* Fetch each domain and add it to the list, unless ignore. */
715 for (int i = 0; i < n; ++i) {
716 virDomainPtr dom = NULL;
719 xmlDocPtr xml_doc = NULL;
720 xmlXPathContextPtr xpath_ctx = NULL;
721 xmlXPathObjectPtr xpath_obj = NULL;
723 dom = virDomainLookupByID (conn, domids[i]);
725 VIRT_ERROR (conn, "virDomainLookupByID");
726 /* Could be that the domain went away -- ignore it anyway. */
730 name = virDomainGetName (dom);
732 VIRT_ERROR (conn, "virDomainGetName");
736 if (il_domains && ignorelist_match (il_domains, name) != 0)
739 if (add_domain (dom) < 0) {
740 ERROR (PLUGIN_NAME " plugin: malloc failed.");
744 /* Get a list of devices for this domain. */
745 xml = virDomainGetXMLDesc (dom, 0);
747 VIRT_ERROR (conn, "virDomainGetXMLDesc");
751 /* Yuck, XML. Parse out the devices. */
752 xml_doc = xmlReadDoc ((xmlChar *) xml, NULL, NULL, XML_PARSE_NONET);
753 if (xml_doc == NULL) {
754 VIRT_ERROR (conn, "xmlReadDoc");
758 xpath_ctx = xmlXPathNewContext (xml_doc);
761 char * bd_xmlpath=NULL;
762 if( source == blockdevice_format ){
763 bd_xmlpath="/domain/devices/disk/source[@dev]";
765 if( dev == blockdevice_format ){
766 bd_xmlpath="/domain/devices/disk/target[@dev]";
769 xpath_obj = xmlXPathEval
770 ((xmlChar *) bd_xmlpath,
773 if (xpath_obj == NULL || xpath_obj->type != XPATH_NODESET ||
774 xpath_obj->nodesetval == NULL)
777 for (int j = 0; j < xpath_obj->nodesetval->nodeNr; ++j) {
781 node = xpath_obj->nodesetval->nodeTab[j];
783 path = (char *) xmlGetProp (node, (xmlChar *) "dev");
786 if (il_block_devices &&
787 ignore_device_match (il_block_devices, name, path) != 0)
790 add_block_device (dom, path);
792 if (path) xmlFree (path);
794 xmlXPathFreeObject (xpath_obj);
796 /* Network interfaces. */
797 xpath_obj = xmlXPathEval
798 ((xmlChar *) "/domain/devices/interface[target[@dev]]",
800 if (xpath_obj == NULL || xpath_obj->type != XPATH_NODESET ||
801 xpath_obj->nodesetval == NULL)
804 xmlNodeSetPtr xml_interfaces = xpath_obj->nodesetval;
806 for (int j = 0; j < xml_interfaces->nodeNr; ++j) {
808 char *address = NULL;
809 xmlNodePtr xml_interface;
811 xml_interface = xml_interfaces->nodeTab[j];
812 if (!xml_interface) continue;
814 for (xmlNodePtr child = xml_interface->children; child; child = child->next) {
815 if (child->type != XML_ELEMENT_NODE) continue;
817 if (xmlStrEqual(child->name, (const xmlChar *) "target")) {
818 path = (char *) xmlGetProp (child, (const xmlChar *) "dev");
820 } else if (xmlStrEqual(child->name, (const xmlChar *) "mac")) {
821 address = (char *) xmlGetProp (child, (const xmlChar *) "address");
822 if (!address) continue;
826 if (il_interface_devices &&
827 (ignore_device_match (il_interface_devices, name, path) != 0 ||
828 ignore_device_match (il_interface_devices, name, address) != 0))
831 add_interface_device (dom, path, address, j+1);
833 if (path) xmlFree (path);
834 if (address) xmlFree (address);
838 if (xpath_obj) xmlXPathFreeObject (xpath_obj);
839 if (xpath_ctx) xmlXPathFreeContext (xpath_ctx);
840 if (xml_doc) xmlFreeDoc (xml_doc);
854 for (int i = 0; i < nr_domains; ++i)
855 virDomainFree (domains[i]);
863 add_domain (virDomainPtr dom)
865 virDomainPtr *new_ptr;
866 int new_size = sizeof (domains[0]) * (nr_domains+1);
869 new_ptr = realloc (domains, new_size);
871 new_ptr = malloc (new_size);
877 domains[nr_domains] = dom;
882 free_block_devices (void)
885 for (int i = 0; i < nr_block_devices; ++i)
886 sfree (block_devices[i].path);
887 sfree (block_devices);
889 block_devices = NULL;
890 nr_block_devices = 0;
894 add_block_device (virDomainPtr dom, const char *path)
896 struct block_device *new_ptr;
897 int new_size = sizeof (block_devices[0]) * (nr_block_devices+1);
900 path_copy = strdup (path);
905 new_ptr = realloc (block_devices, new_size);
907 new_ptr = malloc (new_size);
909 if (new_ptr == NULL) {
913 block_devices = new_ptr;
914 block_devices[nr_block_devices].dom = dom;
915 block_devices[nr_block_devices].path = path_copy;
916 return nr_block_devices++;
920 free_interface_devices (void)
922 if (interface_devices) {
923 for (int i = 0; i < nr_interface_devices; ++i) {
924 sfree (interface_devices[i].path);
925 sfree (interface_devices[i].address);
926 sfree (interface_devices[i].number);
928 sfree (interface_devices);
930 interface_devices = NULL;
931 nr_interface_devices = 0;
935 add_interface_device (virDomainPtr dom, const char *path, const char *address, unsigned int number)
937 struct interface_device *new_ptr;
938 int new_size = sizeof (interface_devices[0]) * (nr_interface_devices+1);
939 char *path_copy, *address_copy, number_string[15];
941 if ((path == NULL) || (address == NULL))
944 path_copy = strdup (path);
945 if (!path_copy) return -1;
947 address_copy = strdup (address);
953 snprintf(number_string, sizeof (number_string), "interface-%u", number);
955 if (interface_devices)
956 new_ptr = realloc (interface_devices, new_size);
958 new_ptr = malloc (new_size);
960 if (new_ptr == NULL) {
962 sfree (address_copy);
965 interface_devices = new_ptr;
966 interface_devices[nr_interface_devices].dom = dom;
967 interface_devices[nr_interface_devices].path = path_copy;
968 interface_devices[nr_interface_devices].address = address_copy;
969 interface_devices[nr_interface_devices].number = strdup(number_string);
970 return nr_interface_devices++;
974 ignore_device_match (ignorelist_t *il, const char *domname, const char *devpath)
979 if ((domname == NULL) || (devpath == NULL))
982 n = sizeof (char) * (strlen (domname) + strlen (devpath) + 2);
985 ERROR (PLUGIN_NAME " plugin: malloc failed.");
988 ssnprintf (name, n, "%s:%s", domname, devpath);
989 r = ignorelist_match (il, name);
997 free_block_devices ();
998 free_interface_devices ();
1002 virConnectClose (conn);
1005 ignorelist_free (il_domains);
1007 ignorelist_free (il_block_devices);
1008 il_block_devices = NULL;
1009 ignorelist_free (il_interface_devices);
1010 il_interface_devices = NULL;
1016 module_register (void)
1018 plugin_register_config (PLUGIN_NAME,
1020 config_keys, NR_CONFIG_KEYS);
1021 plugin_register_init (PLUGIN_NAME, lv_init);
1022 plugin_register_read (PLUGIN_NAME, lv_read);
1023 plugin_register_shutdown (PLUGIN_NAME, lv_shutdown);
1027 * vim: shiftwidth=4 tabstop=8 softtabstop=4 expandtab fdm=marker