Many build fixes that turned up with GCC 4.6.
[collectd.git] / src / libvirt.c
1 /**
2  * collectd - src/libvirt.c
3  * Copyright (C) 2006-2008  Red Hat Inc.
4  *
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.
8  *
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.
13  *
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
17  *
18  * Authors:
19  *   Richard W.M. Jones <rjones@redhat.com>
20  **/
21
22 #include "collectd.h"
23 #include "common.h"
24 #include "plugin.h"
25 #include "configfile.h"
26 #include "utils_ignorelist.h"
27 #include "utils_complain.h"
28
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>
34
35 static const char *config_keys[] = {
36     "Connection",
37
38     "RefreshInterval",
39
40     "Domain",
41     "BlockDevice",
42     "InterfaceDevice",
43     "IgnoreSelected",
44
45     "HostnameFormat",
46
47     NULL
48 };
49 #define NR_CONFIG_KEYS ((sizeof config_keys / sizeof config_keys[0]) - 1)
50
51 /* Connection. */
52 static virConnectPtr conn = 0;
53 static char *conn_string = NULL;
54 static c_complain_t conn_complain = C_COMPLAIN_INIT_STATIC;
55
56 /* Seconds between list refreshes, 0 disables completely. */
57 static int interval = 60;
58
59 /* List of domains, if specified. */
60 static ignorelist_t *il_domains = NULL;
61 /* List of block devices, if specified. */
62 static ignorelist_t *il_block_devices = NULL;
63 /* List of network interface devices, if specified. */
64 static ignorelist_t *il_interface_devices = NULL;
65
66 static int ignore_device_match (ignorelist_t *,
67                                 const char *domname, const char *devpath);
68
69 /* Actual list of domains found on last refresh. */
70 static virDomainPtr *domains = NULL;
71 static int nr_domains = 0;
72
73 static void free_domains (void);
74 static int add_domain (virDomainPtr dom);
75
76 /* Actual list of block devices found on last refresh. */
77 struct block_device {
78     virDomainPtr dom;           /* domain */
79     char *path;                 /* name of block device */
80 };
81
82 static struct block_device *block_devices = NULL;
83 static int nr_block_devices = 0;
84
85 static void free_block_devices (void);
86 static int add_block_device (virDomainPtr dom, const char *path);
87
88 /* Actual list of network interfaces found on last refresh. */
89 struct interface_device {
90     virDomainPtr dom;           /* domain */
91     char *path;                 /* name of interface device */
92 };
93
94 static struct interface_device *interface_devices = NULL;
95 static int nr_interface_devices = 0;
96
97 static void free_interface_devices (void);
98 static int add_interface_device (virDomainPtr dom, const char *path);
99
100 /* HostnameFormat. */
101 #define HF_MAX_FIELDS 3
102
103 enum hf_field {
104     hf_none = 0,
105     hf_hostname,
106     hf_name,
107     hf_uuid
108 };
109
110 static enum hf_field hostname_format[HF_MAX_FIELDS] =
111     { hf_name };
112
113 /* Time that we last refreshed. */
114 static time_t last_refresh = (time_t) 0;
115
116 static int refresh_lists (void);
117
118 /* Submit functions. */
119 static void cpu_submit (unsigned long long cpu_time,
120                         time_t t,
121                         virDomainPtr dom, const char *type);
122 static void vcpu_submit (unsigned long long cpu_time,
123                          time_t t,
124                          virDomainPtr dom, int vcpu_nr, const char *type);
125 static void submit_counter2 (const char *type, counter_t v0, counter_t v1,
126              time_t t,
127              virDomainPtr dom, const char *devname);
128
129 /* ERROR(...) macro for virterrors. */
130 #define VIRT_ERROR(conn,s) do {                 \
131         virErrorPtr err;                        \
132         err = (conn) ? virConnGetLastError ((conn)) : virGetLastError (); \
133         if (err) ERROR ("%s: %s", (s), err->message);                   \
134     } while(0)
135
136 static int
137 lv_init (void)
138 {
139     if (virInitialize () != 0)
140         return -1;
141
142         return 0;
143 }
144
145 static int
146 lv_config (const char *key, const char *value)
147 {
148     if (virInitialize () != 0)
149         return 1;
150
151     if (il_domains == NULL)
152         il_domains = ignorelist_create (1);
153     if (il_block_devices == NULL)
154         il_block_devices = ignorelist_create (1);
155     if (il_interface_devices == NULL)
156         il_interface_devices = ignorelist_create (1);
157
158     if (strcasecmp (key, "Connection") == 0) {
159         char *tmp = strdup (value);
160         if (tmp == NULL) {
161             ERROR ("libvirt plugin: Connection strdup failed.");
162             return 1;
163         }
164         sfree (conn_string);
165         conn_string = tmp;
166         return 0;
167     }
168
169     if (strcasecmp (key, "RefreshInterval") == 0) {
170         char *eptr = NULL;
171         interval = strtol (value, &eptr, 10);
172         if (eptr == NULL || *eptr != '\0') return 1;
173         return 0;
174     }
175
176     if (strcasecmp (key, "Domain") == 0) {
177         if (ignorelist_add (il_domains, value)) return 1;
178         return 0;
179     }
180     if (strcasecmp (key, "BlockDevice") == 0) {
181         if (ignorelist_add (il_block_devices, value)) return 1;
182         return 0;
183     }
184     if (strcasecmp (key, "InterfaceDevice") == 0) {
185         if (ignorelist_add (il_interface_devices, value)) return 1;
186         return 0;
187     }
188
189     if (strcasecmp (key, "IgnoreSelected") == 0) {
190         if (IS_TRUE (value))
191         {
192             ignorelist_set_invert (il_domains, 0);
193             ignorelist_set_invert (il_block_devices, 0);
194             ignorelist_set_invert (il_interface_devices, 0);
195         }
196         else
197         {
198             ignorelist_set_invert (il_domains, 1);
199             ignorelist_set_invert (il_block_devices, 1);
200             ignorelist_set_invert (il_interface_devices, 1);
201         }
202         return 0;
203     }
204
205     if (strcasecmp (key, "HostnameFormat") == 0) {
206         char *value_copy;
207         char *fields[HF_MAX_FIELDS];
208         int i, n;
209
210         value_copy = strdup (value);
211         if (value_copy == NULL) {
212             ERROR ("libvirt plugin: strdup failed.");
213             return -1;
214         }
215
216         n = strsplit (value_copy, fields, HF_MAX_FIELDS);
217         if (n < 1) {
218             free (value_copy);
219             ERROR ("HostnameFormat: no fields");
220             return -1;
221         }
222
223         for (i = 0; i < n; ++i) {
224             if (strcasecmp (fields[i], "hostname") == 0)
225                 hostname_format[i] = hf_hostname;
226             else if (strcasecmp (fields[i], "name") == 0)
227                 hostname_format[i] = hf_name;
228             else if (strcasecmp (fields[i], "uuid") == 0)
229                 hostname_format[i] = hf_uuid;
230             else {
231                 free (value_copy);
232                 ERROR ("unknown HostnameFormat field: %s", fields[i]);
233                 return -1;
234             }
235         }
236         free (value_copy);
237
238         for (i = n; i < HF_MAX_FIELDS; ++i)
239             hostname_format[i] = hf_none;
240
241         return 0;
242     }
243
244     /* Unrecognised option. */
245     return -1;
246 }
247
248 static int
249 lv_read (void)
250 {
251     time_t t;
252     int i;
253
254     if (conn == NULL) {
255         /* `conn_string == NULL' is acceptable. */
256         conn = virConnectOpenReadOnly (conn_string);
257         if (conn == NULL) {
258             c_complain (LOG_ERR, &conn_complain,
259                     "libvirt plugin: Unable to connect: "
260                     "virConnectOpenReadOnly failed.");
261             return -1;
262         }
263     }
264     c_release (LOG_NOTICE, &conn_complain,
265             "libvirt plugin: Connection established.");
266
267     time (&t);
268
269     /* Need to refresh domain or device lists? */
270     if ((last_refresh == (time_t) 0) ||
271             ((interval > 0) && ((last_refresh + interval) <= t))) {
272         if (refresh_lists () != 0) {
273             if (conn != NULL)
274                 virConnectClose (conn);
275             conn = NULL;
276             return -1;
277         }
278         last_refresh = t;
279     }
280
281 #if 0
282     for (i = 0; i < nr_domains; ++i)
283         fprintf (stderr, "domain %s\n", virDomainGetName (domains[i]));
284     for (i = 0; i < nr_block_devices; ++i)
285         fprintf  (stderr, "block device %d %s:%s\n",
286                   i, virDomainGetName (block_devices[i].dom),
287                   block_devices[i].path);
288     for (i = 0; i < nr_interface_devices; ++i)
289         fprintf (stderr, "interface device %d %s:%s\n",
290                  i, virDomainGetName (interface_devices[i].dom),
291                  interface_devices[i].path);
292 #endif
293
294     /* Get CPU usage, VCPU usage for each domain. */
295     for (i = 0; i < nr_domains; ++i) {
296         virDomainInfo info;
297         virVcpuInfoPtr vinfo = NULL;
298         int status;
299         int j;
300
301         status = virDomainGetInfo (domains[i], &info);
302         if (status != 0)
303         {
304             ERROR ("libvirt plugin: virDomainGetInfo failed with status %i.",
305                     status);
306             continue;
307         }
308
309         cpu_submit (info.cpuTime, t, domains[i], "virt_cpu_total");
310
311         vinfo = malloc (info.nrVirtCpu * sizeof (vinfo[0]));
312         if (vinfo == NULL) {
313             ERROR ("libvirt plugin: malloc failed.");
314             continue;
315         }
316
317         status = virDomainGetVcpus (domains[i], vinfo, info.nrVirtCpu,
318                 /* cpu map = */ NULL, /* cpu map length = */ 0);
319         if (status < 0)
320         {
321             ERROR ("libvirt plugin: virDomainGetVcpus failed with status %i.",
322                     status);
323             free (vinfo);
324             continue;
325         }
326
327         for (j = 0; j < info.nrVirtCpu; ++j)
328             vcpu_submit (vinfo[j].cpuTime,
329                     t, domains[i], vinfo[j].number, "virt_vcpu");
330
331         free (vinfo);
332     }
333
334     /* Get block device stats for each domain. */
335     for (i = 0; i < nr_block_devices; ++i) {
336         struct _virDomainBlockStats stats;
337
338         if (virDomainBlockStats (block_devices[i].dom, block_devices[i].path,
339                     &stats, sizeof stats) != 0)
340             continue;
341
342         if ((stats.rd_req != -1) && (stats.wr_req != -1))
343             submit_counter2 ("disk_ops",
344                     (counter_t) stats.rd_req, (counter_t) stats.wr_req,
345                     t, block_devices[i].dom, block_devices[i].path);
346
347         if ((stats.rd_bytes != -1) && (stats.wr_bytes != -1))
348             submit_counter2 ("disk_octets",
349                     (counter_t) stats.rd_bytes, (counter_t) stats.wr_bytes,
350                     t, block_devices[i].dom, block_devices[i].path);
351     } /* for (nr_block_devices) */
352
353     /* Get interface stats for each domain. */
354     for (i = 0; i < nr_interface_devices; ++i) {
355         struct _virDomainInterfaceStats stats;
356
357         if (virDomainInterfaceStats (interface_devices[i].dom,
358                     interface_devices[i].path,
359                     &stats, sizeof stats) != 0)
360             continue;
361
362         if ((stats.rx_bytes != -1) && (stats.tx_bytes != -1))
363             submit_counter2 ("if_octets",
364                     (counter_t) stats.rx_bytes, (counter_t) stats.tx_bytes,
365                     t, interface_devices[i].dom, interface_devices[i].path);
366
367         if ((stats.rx_packets != -1) && (stats.tx_packets != -1))
368             submit_counter2 ("if_packets",
369                     (counter_t) stats.rx_packets, (counter_t) stats.tx_packets,
370                     t, interface_devices[i].dom, interface_devices[i].path);
371
372         if ((stats.rx_errs != -1) && (stats.tx_errs != -1))
373             submit_counter2 ("if_errors",
374                     (counter_t) stats.rx_errs, (counter_t) stats.tx_errs,
375                     t, interface_devices[i].dom, interface_devices[i].path);
376
377         if ((stats.rx_drop != -1) && (stats.tx_drop != -1))
378             submit_counter2 ("if_dropped",
379                     (counter_t) stats.rx_drop, (counter_t) stats.tx_drop,
380                     t, interface_devices[i].dom, interface_devices[i].path);
381     } /* for (nr_interface_devices) */
382
383     return 0;
384 }
385
386 static int
387 refresh_lists (void)
388 {
389     int n;
390
391     n = virConnectNumOfDomains (conn);
392     if (n < 0) {
393         VIRT_ERROR (conn, "reading number of domains");
394         return -1;
395     }
396
397     if (n > 0) {
398         int i;
399         int *domids;
400
401         /* Get list of domains. */
402         domids = malloc (sizeof (int) * n);
403         if (domids == 0) {
404             ERROR ("libvirt plugin: malloc failed.");
405             return -1;
406         }
407
408         n = virConnectListDomains (conn, domids, n);
409         if (n < 0) {
410             VIRT_ERROR (conn, "reading list of domains");
411             free (domids);
412             return -1;
413         }
414
415         free_block_devices ();
416         free_interface_devices ();
417         free_domains ();
418
419         /* Fetch each domain and add it to the list, unless ignore. */
420         for (i = 0; i < n; ++i) {
421             virDomainPtr dom = NULL;
422             const char *name;
423             char *xml = NULL;
424             xmlDocPtr xml_doc = NULL;
425             xmlXPathContextPtr xpath_ctx = NULL;
426             xmlXPathObjectPtr xpath_obj = NULL;
427             int j;
428
429             dom = virDomainLookupByID (conn, domids[i]);
430             if (dom == NULL) {
431                 VIRT_ERROR (conn, "virDomainLookupByID");
432                 /* Could be that the domain went away -- ignore it anyway. */
433                 continue;
434             }
435
436             name = virDomainGetName (dom);
437             if (name == NULL) {
438                 VIRT_ERROR (conn, "virDomainGetName");
439                 goto cont;
440             }
441
442             if (il_domains && ignorelist_match (il_domains, name) != 0)
443                 goto cont;
444
445             if (add_domain (dom) < 0) {
446                 ERROR ("libvirt plugin: malloc failed.");
447                 goto cont;
448             }
449
450             /* Get a list of devices for this domain. */
451             xml = virDomainGetXMLDesc (dom, 0);
452             if (!xml) {
453                 VIRT_ERROR (conn, "virDomainGetXMLDesc");
454                 goto cont;
455             }
456
457             /* Yuck, XML.  Parse out the devices. */
458             xml_doc = xmlReadDoc ((xmlChar *) xml, NULL, NULL, XML_PARSE_NONET);
459             if (xml_doc == NULL) {
460                 VIRT_ERROR (conn, "xmlReadDoc");
461                 goto cont;
462             }
463
464             xpath_ctx = xmlXPathNewContext (xml_doc);
465
466             /* Block devices. */
467             xpath_obj = xmlXPathEval
468                 ((xmlChar *) "/domain/devices/disk/target[@dev]",
469                  xpath_ctx);
470             if (xpath_obj == NULL || xpath_obj->type != XPATH_NODESET ||
471                 xpath_obj->nodesetval == NULL)
472                 goto cont;
473
474             for (j = 0; j < xpath_obj->nodesetval->nodeNr; ++j) {
475                 xmlNodePtr node;
476                 char *path = NULL;
477
478                 node = xpath_obj->nodesetval->nodeTab[j];
479                 if (!node) continue;
480                 path = (char *) xmlGetProp (node, (xmlChar *) "dev");
481                 if (!path) continue;
482
483                 if (il_block_devices &&
484                     ignore_device_match (il_block_devices, name, path) != 0)
485                     goto cont2;
486
487                 add_block_device (dom, path);
488             cont2:
489                 if (path) xmlFree (path);
490             }
491             xmlXPathFreeObject (xpath_obj);
492
493             /* Network interfaces. */
494             xpath_obj = xmlXPathEval
495                 ((xmlChar *) "/domain/devices/interface/target[@dev]",
496                  xpath_ctx);
497             if (xpath_obj == NULL || xpath_obj->type != XPATH_NODESET ||
498                 xpath_obj->nodesetval == NULL)
499                 goto cont;
500
501             for (j = 0; j < xpath_obj->nodesetval->nodeNr; ++j) {
502                 xmlNodePtr node;
503                 char *path = NULL;
504
505                 node = xpath_obj->nodesetval->nodeTab[j];
506                 if (!node) continue;
507                 path = (char *) xmlGetProp (node, (xmlChar *) "dev");
508                 if (!path) continue;
509
510                 if (il_interface_devices &&
511                     ignore_device_match (il_interface_devices, name, path) != 0)
512                     goto cont3;
513
514                 add_interface_device (dom, path);
515             cont3:
516                 if (path) xmlFree (path);
517             }
518
519         cont:
520             if (xpath_obj) xmlXPathFreeObject (xpath_obj);
521             if (xpath_ctx) xmlXPathFreeContext (xpath_ctx);
522             if (xml_doc) xmlFreeDoc (xml_doc);
523             if (xml) free (xml);
524         }
525
526         free (domids);
527     }
528
529     return 0;
530 }
531
532 static void
533 free_domains ()
534 {
535     int i;
536
537     if (domains) {
538         for (i = 0; i < nr_domains; ++i)
539             virDomainFree (domains[i]);
540         free (domains);
541     }
542     domains = NULL;
543     nr_domains = 0;
544 }
545
546 static int
547 add_domain (virDomainPtr dom)
548 {
549     virDomainPtr *new_ptr;
550     int new_size = sizeof (domains[0]) * (nr_domains+1);
551
552     if (domains)
553         new_ptr = realloc (domains, new_size);
554     else
555         new_ptr = malloc (new_size);
556
557     if (new_ptr == NULL)
558         return -1;
559
560     domains = new_ptr;
561     domains[nr_domains] = dom;
562     return nr_domains++;
563 }
564
565 static void
566 free_block_devices ()
567 {
568     int i;
569
570     if (block_devices) {
571         for (i = 0; i < nr_block_devices; ++i)
572             free (block_devices[i].path);
573         free (block_devices);
574     }
575     block_devices = NULL;
576     nr_block_devices = 0;
577 }
578
579 static int
580 add_block_device (virDomainPtr dom, const char *path)
581 {
582     struct block_device *new_ptr;
583     int new_size = sizeof (block_devices[0]) * (nr_block_devices+1);
584     char *path_copy;
585
586     path_copy = strdup (path);
587     if (!path_copy)
588         return -1;
589
590     if (block_devices)
591         new_ptr = realloc (block_devices, new_size);
592     else
593         new_ptr = malloc (new_size);
594
595     if (new_ptr == NULL) {
596         free (path_copy);
597         return -1;
598     }
599     block_devices = new_ptr;
600     block_devices[nr_block_devices].dom = dom;
601     block_devices[nr_block_devices].path = path_copy;
602     return nr_block_devices++;
603 }
604
605 static void
606 free_interface_devices ()
607 {
608     int i;
609
610     if (interface_devices) {
611         for (i = 0; i < nr_interface_devices; ++i)
612             free (interface_devices[i].path);
613         free (interface_devices);
614     }
615     interface_devices = NULL;
616     nr_interface_devices = 0;
617 }
618
619 static int
620 add_interface_device (virDomainPtr dom, const char *path)
621 {
622     struct interface_device *new_ptr;
623     int new_size = sizeof (interface_devices[0]) * (nr_interface_devices+1);
624     char *path_copy;
625
626     path_copy = strdup (path);
627     if (!path_copy) return -1;
628
629     if (interface_devices)
630         new_ptr = realloc (interface_devices, new_size);
631     else
632         new_ptr = malloc (new_size);
633
634     if (new_ptr == NULL) {
635         free (path_copy);
636         return -1;
637     }
638     interface_devices = new_ptr;
639     interface_devices[nr_interface_devices].dom = dom;
640     interface_devices[nr_interface_devices].path = path_copy;
641     return nr_interface_devices++;
642 }
643
644 static int
645 ignore_device_match (ignorelist_t *il, const char *domname, const char *devpath)
646 {
647     char *name;
648     int n, r;
649
650     n = sizeof (char) * (strlen (domname) + strlen (devpath) + 2);
651     name = malloc (n);
652     if (name == NULL) {
653         ERROR ("libvirt plugin: malloc failed.");
654         return 0;
655     }
656     ssnprintf (name, n, "%s:%s", domname, devpath);
657     r = ignorelist_match (il, name);
658     free (name);
659     return r;
660 }
661
662 static void
663 init_value_list (value_list_t *vl, time_t t, virDomainPtr dom)
664 {
665     int i, n;
666     const char *name;
667     char uuid[VIR_UUID_STRING_BUFLEN];
668
669     vl->time = t;
670     vl->interval = interval_g;
671
672     sstrncpy (vl->plugin, "libvirt", sizeof (vl->plugin));
673
674     vl->host[0] = '\0';
675
676     /* Construct the hostname field according to HostnameFormat. */
677     for (i = 0; i < HF_MAX_FIELDS; ++i) {
678         if (hostname_format[i] == hf_none)
679             continue;
680
681         n = DATA_MAX_NAME_LEN - strlen (vl->host) - 2;
682
683         if (i > 0 && n >= 1) {
684             strncat (vl->host, ":", 1);
685             n--;
686         }
687
688         switch (hostname_format[i]) {
689         case hf_none: break;
690         case hf_hostname:
691             strncat (vl->host, hostname_g, n);
692             break;
693         case hf_name:
694             name = virDomainGetName (dom);
695             if (name)
696                 strncat (vl->host, name, n);
697             break;
698         case hf_uuid:
699             if (virDomainGetUUIDString (dom, uuid) == 0)
700                 strncat (vl->host, uuid, n);
701             break;
702         }
703     }
704
705     vl->host[sizeof (vl->host) - 1] = '\0';
706 } /* void init_value_list */
707
708 static void
709 cpu_submit (unsigned long long cpu_time,
710             time_t t,
711             virDomainPtr dom, const char *type)
712 {
713     value_t values[1];
714     value_list_t vl = VALUE_LIST_INIT;
715
716     init_value_list (&vl, t, dom);
717
718     values[0].counter = cpu_time;
719
720     vl.values = values;
721     vl.values_len = 1;
722
723     sstrncpy (vl.type, type, sizeof (vl.type));
724
725     plugin_dispatch_values (&vl);
726 }
727
728 static void
729 vcpu_submit (counter_t cpu_time,
730              time_t t,
731              virDomainPtr dom, int vcpu_nr, const char *type)
732 {
733     value_t values[1];
734     value_list_t vl = VALUE_LIST_INIT;
735
736     init_value_list (&vl, t, dom);
737
738     values[0].counter = cpu_time;
739     vl.values = values;
740     vl.values_len = 1;
741
742     sstrncpy (vl.type, type, sizeof (vl.type));
743     ssnprintf (vl.type_instance, sizeof (vl.type_instance), "%d", vcpu_nr);
744
745     plugin_dispatch_values (&vl);
746 }
747
748 static void
749 submit_counter2 (const char *type, counter_t v0, counter_t v1,
750              time_t t,
751              virDomainPtr dom, const char *devname)
752 {
753     value_t values[2];
754     value_list_t vl = VALUE_LIST_INIT;
755
756     init_value_list (&vl, t, dom);
757
758     values[0].counter = v0;
759     values[1].counter = v1;
760     vl.values = values;
761     vl.values_len = 2;
762
763     sstrncpy (vl.type, type, sizeof (vl.type));
764     sstrncpy (vl.type_instance, devname, sizeof (vl.type_instance));
765
766     plugin_dispatch_values (&vl);
767 } /* void submit_counter2 */
768
769 static int
770 lv_shutdown (void)
771 {
772     free_block_devices ();
773     free_interface_devices ();
774     free_domains ();
775
776     if (conn != NULL)
777         virConnectClose (conn);
778     conn = NULL;
779
780     ignorelist_free (il_domains);
781     il_domains = NULL;
782     ignorelist_free (il_block_devices);
783     il_block_devices = NULL;
784     ignorelist_free (il_interface_devices);
785     il_interface_devices = NULL;
786
787     return 0;
788 }
789
790 void
791 module_register (void)
792 {
793     plugin_register_config ("libvirt",
794             lv_config,
795             config_keys, NR_CONFIG_KEYS);
796     plugin_register_init ("libvirt", lv_init);
797     plugin_register_read ("libvirt", lv_read);
798     plugin_register_shutdown ("libvirt", lv_shutdown);
799 }
800
801 /*
802  * vim: shiftwidth=4 tabstop=8 softtabstop=4 expandtab fdm=marker
803  */