2 * libvirt-network.c: entry points for virNetworkPtr APIs
4 * Copyright (C) 2006-2015 Red Hat, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library. If not, see
18 * <http://www.gnu.org/licenses/>.
23 #include "datatypes.h"
26 #include "virtypedparam.h"
28 VIR_LOG_INIT("libvirt.network");
30 #define VIR_FROM_THIS VIR_FROM_NETWORK
33 * virNetworkGetConnect:
34 * @net: pointer to a network
36 * Provides the connection pointer associated with a network. The
37 * reference counter on the connection is not increased by this
40 * Returns the virConnectPtr or NULL in case of failure.
45 virNetworkGetConnect(virNetworkPtr net
)
47 VIR_DEBUG("net=%p", net
);
51 virCheckNetworkReturn(net
, NULL
);
58 * virConnectListAllNetworks:
59 * @conn: Pointer to the hypervisor connection.
60 * @nets: Pointer to a variable to store the array containing the network
61 * objects or NULL if the list is not required (just returns number
63 * @flags: bitwise-OR of virConnectListAllNetworksFlags.
65 * Collect the list of networks, and allocate an array to store those
66 * objects. This API solves the race inherent between virConnectListNetworks
67 * and virConnectListDefinedNetworks.
69 * Normally, all networks are returned; however, @flags can be used to
70 * filter the results for a smaller list of targeted networks. The valid
71 * flags are divided into groups, where each group contains bits that
72 * describe mutually exclusive attributes of a network, and where all bits
73 * within a group describe all possible networks.
75 * The first group of @flags is VIR_CONNECT_LIST_NETWORKS_ACTIVE (up) and
76 * VIR_CONNECT_LIST_NETWORKS_INACTIVE (down) to filter the networks by state.
78 * The second group of @flags is VIR_CONNECT_LIST_NETWORKS_PERSISTENT (defined)
79 * and VIR_CONNECT_LIST_NETWORKS_TRANSIENT (running but not defined), to filter
80 * the networks by whether they have persistent config or not.
82 * The third group of @flags is VIR_CONNECT_LIST_NETWORKS_AUTOSTART
83 * and VIR_CONNECT_LIST_NETWORKS_NO_AUTOSTART, to filter the networks by
84 * whether they are marked as autostart or not.
86 * Returns the number of networks found or -1 and sets @nets to NULL in case
87 * of error. On success, the array stored into @nets is guaranteed to have an
88 * extra allocated element set to NULL but not included in the return count,
89 * to make iteration easier. The caller is responsible for calling
90 * virNetworkFree() on each array element, then calling free() on @nets.
95 virConnectListAllNetworks(virConnectPtr conn
,
99 VIR_DEBUG("conn=%p, nets=%p, flags=0x%x", conn
, nets
, flags
);
106 virCheckConnectReturn(conn
, -1);
108 if (conn
->networkDriver
&&
109 conn
->networkDriver
->connectListAllNetworks
) {
111 ret
= conn
->networkDriver
->connectListAllNetworks(conn
, nets
, flags
);
117 virReportUnsupportedError();
120 virDispatchError(conn
);
126 * virConnectNumOfNetworks:
127 * @conn: pointer to the hypervisor connection
129 * Provides the number of active networks.
131 * Returns the number of network found or -1 in case of error
136 virConnectNumOfNetworks(virConnectPtr conn
)
138 VIR_DEBUG("conn=%p", conn
);
142 virCheckConnectReturn(conn
, -1);
144 if (conn
->networkDriver
&& conn
->networkDriver
->connectNumOfNetworks
) {
146 ret
= conn
->networkDriver
->connectNumOfNetworks(conn
);
152 virReportUnsupportedError();
155 virDispatchError(conn
);
161 * virConnectListNetworks:
162 * @conn: pointer to the hypervisor connection
163 * @names: array to collect the list of names of active networks
164 * @maxnames: size of @names
166 * Collect the list of active networks, and store their names in @names
168 * The use of this function is discouraged. Instead, use
169 * virConnectListAllNetworks().
171 * Returns the number of networks found or -1 in case of error. Note that
172 * this command is inherently racy; a network can be started between a call
173 * to virConnectNumOfNetworks() and this call; you are only guaranteed that
174 * all currently active networks were listed if the return is less than
175 * @maxnames. The client must call free() on each returned name.
180 virConnectListNetworks(virConnectPtr conn
, char **const names
, int maxnames
)
182 VIR_DEBUG("conn=%p, names=%p, maxnames=%d", conn
, names
, maxnames
);
186 virCheckConnectReturn(conn
, -1);
187 virCheckNonNullArrayArgGoto(names
, maxnames
, error
);
188 virCheckNonNegativeArgGoto(maxnames
, error
);
190 if (conn
->networkDriver
&& conn
->networkDriver
->connectListNetworks
) {
192 ret
= conn
->networkDriver
->connectListNetworks(conn
, names
, maxnames
);
198 virReportUnsupportedError();
201 virDispatchError(conn
);
207 * virConnectNumOfDefinedNetworks:
208 * @conn: pointer to the hypervisor connection
210 * Provides the number of inactive networks.
212 * Returns the number of networks found or -1 in case of error
217 virConnectNumOfDefinedNetworks(virConnectPtr conn
)
219 VIR_DEBUG("conn=%p", conn
);
223 virCheckConnectReturn(conn
, -1);
225 if (conn
->networkDriver
&& conn
->networkDriver
->connectNumOfDefinedNetworks
) {
227 ret
= conn
->networkDriver
->connectNumOfDefinedNetworks(conn
);
233 virReportUnsupportedError();
236 virDispatchError(conn
);
242 * virConnectListDefinedNetworks:
243 * @conn: pointer to the hypervisor connection
244 * @names: pointer to an array to store the names
245 * @maxnames: size of the array
247 * list the inactive networks, stores the pointers to the names in @names
249 * The use of this function is discouraged. Instead, use
250 * virConnectListAllNetworks().
252 * Returns the number of names provided in the array or -1 in case of error.
253 * Note that this command is inherently racy; a network can be defined between
254 * a call to virConnectNumOfDefinedNetworks() and this call; you are only
255 * guaranteed that all currently defined networks were listed if the return
256 * is less than @maxnames. The client must call free() on each returned name.
261 virConnectListDefinedNetworks(virConnectPtr conn
, char **const names
,
264 VIR_DEBUG("conn=%p, names=%p, maxnames=%d", conn
, names
, maxnames
);
268 virCheckConnectReturn(conn
, -1);
269 virCheckNonNullArrayArgGoto(names
, maxnames
, error
);
270 virCheckNonNegativeArgGoto(maxnames
, error
);
272 if (conn
->networkDriver
&& conn
->networkDriver
->connectListDefinedNetworks
) {
274 ret
= conn
->networkDriver
->connectListDefinedNetworks(conn
, names
, maxnames
);
280 virReportUnsupportedError();
283 virDispatchError(conn
);
289 * virNetworkLookupByName:
290 * @conn: pointer to the hypervisor connection
291 * @name: name for the network
293 * Try to lookup a network on the given hypervisor based on its name.
295 * virNetworkFree should be used to free the resources after the
296 * network object is no longer needed.
298 * Returns a new network object or NULL in case of failure. If the
299 * network cannot be found, then VIR_ERR_NO_NETWORK error is raised.
304 virNetworkLookupByName(virConnectPtr conn
, const char *name
)
306 VIR_DEBUG("conn=%p, name=%s", conn
, NULLSTR(name
));
310 virCheckConnectReturn(conn
, NULL
);
311 virCheckNonNullArgGoto(name
, error
);
313 if (conn
->networkDriver
&& conn
->networkDriver
->networkLookupByName
) {
315 ret
= conn
->networkDriver
->networkLookupByName(conn
, name
);
321 virReportUnsupportedError();
324 virDispatchError(conn
);
330 * virNetworkLookupByUUID:
331 * @conn: pointer to the hypervisor connection
332 * @uuid: the raw UUID for the network
334 * Try to lookup a network on the given hypervisor based on its UUID.
336 * virNetworkFree should be used to free the resources after the
337 * network object is no longer needed.
339 * Returns a new network object or NULL in case of failure. If the
340 * network cannot be found, then VIR_ERR_NO_NETWORK error is raised.
345 virNetworkLookupByUUID(virConnectPtr conn
, const unsigned char *uuid
)
347 VIR_UUID_DEBUG(conn
, uuid
);
351 virCheckConnectReturn(conn
, NULL
);
352 virCheckNonNullArgGoto(uuid
, error
);
354 if (conn
->networkDriver
&& conn
->networkDriver
->networkLookupByUUID
) {
356 ret
= conn
->networkDriver
->networkLookupByUUID(conn
, uuid
);
362 virReportUnsupportedError();
365 virDispatchError(conn
);
371 * virNetworkLookupByUUIDString:
372 * @conn: pointer to the hypervisor connection
373 * @uuidstr: the string UUID for the network
375 * Try to lookup a network on the given hypervisor based on its UUID.
377 * Returns a new network object or NULL in case of failure. If the
378 * network cannot be found, then VIR_ERR_NO_NETWORK error is raised.
383 virNetworkLookupByUUIDString(virConnectPtr conn
, const char *uuidstr
)
385 unsigned char uuid
[VIR_UUID_BUFLEN
];
386 VIR_DEBUG("conn=%p, uuidstr=%s", conn
, NULLSTR(uuidstr
));
390 virCheckConnectReturn(conn
, NULL
);
391 virCheckNonNullArgGoto(uuidstr
, error
);
393 if (virUUIDParse(uuidstr
, uuid
) < 0) {
394 virReportInvalidArg(uuidstr
,
395 _("uuidstr in %1$s must be a valid UUID"),
400 return virNetworkLookupByUUID(conn
, &uuid
[0]);
403 virDispatchError(conn
);
409 * virNetworkCreateXML:
410 * @conn: pointer to the hypervisor connection
411 * @xmlDesc: an XML description of the network
413 * Create and start a new virtual network, based on an XML description
414 * similar to the one returned by virNetworkGetXMLDesc()
416 * virNetworkFree should be used to free the resources after the
417 * network object is no longer needed.
419 * Returns a new network object or NULL in case of failure
424 virNetworkCreateXML(virConnectPtr conn
, const char *xmlDesc
)
426 VIR_DEBUG("conn=%p, xmlDesc=%s", conn
, NULLSTR(xmlDesc
));
430 virCheckConnectReturn(conn
, NULL
);
431 virCheckNonNullArgGoto(xmlDesc
, error
);
432 virCheckReadOnlyGoto(conn
->flags
, error
);
434 if (conn
->networkDriver
&& conn
->networkDriver
->networkCreateXML
) {
436 ret
= conn
->networkDriver
->networkCreateXML(conn
, xmlDesc
);
442 virReportUnsupportedError();
445 virDispatchError(conn
);
451 * virNetworkCreateXMLFlags:
452 * @conn: pointer to the hypervisor connection
453 * @xmlDesc: an XML description of the network
454 * @flags: bitwise-OR of virNetworkCreateFlags
456 * Create and start a new virtual network, based on an XML description
457 * similar to the one returned by virNetworkGetXMLDesc()
459 * virNetworkFree should be used to free the resources after the
460 * network object is no longer needed.
462 * Returns a new network object or NULL in case of failure
467 virNetworkCreateXMLFlags(virConnectPtr conn
, const char *xmlDesc
, unsigned int flags
)
469 VIR_DEBUG("conn=%p, xmlDesc=%s, flags=0x%x", conn
, NULLSTR(xmlDesc
), flags
);
473 virCheckConnectReturn(conn
, NULL
);
474 virCheckNonNullArgGoto(xmlDesc
, error
);
475 virCheckReadOnlyGoto(conn
->flags
, error
);
477 if (conn
->networkDriver
&& conn
->networkDriver
->networkCreateXMLFlags
) {
479 ret
= conn
->networkDriver
->networkCreateXMLFlags(conn
, xmlDesc
, flags
);
485 virReportUnsupportedError();
488 virDispatchError(conn
);
494 * virNetworkDefineXML:
495 * @conn: pointer to the hypervisor connection
496 * @xml: the XML description for the network, preferably in UTF-8
498 * Define an inactive persistent virtual network or modify an existing
499 * persistent one from the XML description.
501 * virNetworkFree should be used to free the resources after the
502 * network object is no longer needed.
504 * Returns NULL in case of error, a pointer to the network otherwise
509 virNetworkDefineXML(virConnectPtr conn
, const char *xml
)
511 VIR_DEBUG("conn=%p, xml=%s", conn
, NULLSTR(xml
));
515 virCheckConnectReturn(conn
, NULL
);
516 virCheckReadOnlyGoto(conn
->flags
, error
);
517 virCheckNonNullArgGoto(xml
, error
);
519 if (conn
->networkDriver
&& conn
->networkDriver
->networkDefineXML
) {
521 ret
= conn
->networkDriver
->networkDefineXML(conn
, xml
);
527 virReportUnsupportedError();
530 virDispatchError(conn
);
536 * virNetworkDefineXMLFlags:
537 * @conn: pointer to the hypervisor connection
538 * @xml: the XML description for the network, preferably in UTF-8
539 * @flags: bitwise-OR of virNetworkDefineFlags
541 * Define an inactive persistent virtual network or modify an existing
542 * persistent one from the XML description.
544 * virNetworkFree should be used to free the resources after the
545 * network object is no longer needed.
547 * Returns NULL in case of error, a pointer to the network otherwise
552 virNetworkDefineXMLFlags(virConnectPtr conn
, const char *xml
, unsigned int flags
)
554 VIR_DEBUG("conn=%p, xml=%s, flags=0x%x", conn
, NULLSTR(xml
), flags
);
558 virCheckConnectReturn(conn
, NULL
);
559 virCheckReadOnlyGoto(conn
->flags
, error
);
560 virCheckNonNullArgGoto(xml
, error
);
562 if (conn
->networkDriver
&& conn
->networkDriver
->networkDefineXMLFlags
) {
564 ret
= conn
->networkDriver
->networkDefineXMLFlags(conn
, xml
, flags
);
570 virReportUnsupportedError();
573 virDispatchError(conn
);
579 * virNetworkUndefine:
580 * @network: pointer to a defined network
582 * Undefine a network but does not stop it if it is running
584 * Returns 0 in case of success, -1 in case of error
589 virNetworkUndefine(virNetworkPtr network
)
592 VIR_DEBUG("network=%p", network
);
596 virCheckNetworkReturn(network
, -1);
597 conn
= network
->conn
;
599 virCheckReadOnlyGoto(conn
->flags
, error
);
601 if (conn
->networkDriver
&& conn
->networkDriver
->networkUndefine
) {
603 ret
= conn
->networkDriver
->networkUndefine(network
);
609 virReportUnsupportedError();
612 virDispatchError(network
->conn
);
619 * @network: pointer to a defined network
620 * @section: which section of the network to update
621 * (see virNetworkUpdateSection for descriptions)
622 * @command: what action to perform (add/delete/modify)
623 * (see virNetworkUpdateCommand for descriptions)
624 * @parentIndex: which parent element, if there are multiple parents
625 * of the same type (e.g. which <ip> element when modifying
626 * a <dhcp>/<host> element), or "-1" for "don't care" or
627 * "automatically find appropriate one".
628 * @xml: the XML description for the network, preferably in UTF-8
629 * @flags: bitwise OR of virNetworkUpdateFlags.
631 * Update the definition of an existing network, either its live
632 * running state, its persistent configuration, or both.
634 * Returns 0 in case of success, -1 in case of error
639 virNetworkUpdate(virNetworkPtr network
,
640 unsigned int command
, /* virNetworkUpdateCommand */
641 unsigned int section
, /* virNetworkUpdateSection */
647 VIR_DEBUG("network=%p, command=%d, section=%d, parentIndex=%d, xml=%s, flags=0x%x",
648 network
, command
, section
, parentIndex
, xml
, flags
);
652 virCheckNetworkReturn(network
, -1);
653 conn
= network
->conn
;
655 virCheckReadOnlyGoto(conn
->flags
, error
);
656 virCheckNonNullArgGoto(xml
, error
);
658 if (conn
->networkDriver
&& conn
->networkDriver
->networkUpdate
) {
662 /* Since its introduction in v0.10.2-rc1~9 the @section and @command
663 * arguments were mistakenly swapped when passed to driver's callback.
664 * Detect if the other side is fixed already or not. */
665 rc
= VIR_DRV_SUPPORTS_FEATURE(conn
->driver
, conn
,
666 VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER
);
668 VIR_DEBUG("Argument order feature detection returned: %d", rc
);
673 /* Feature not supported, preserve swapped order */
674 ret
= conn
->networkDriver
->networkUpdate(network
, section
, command
,
675 parentIndex
, xml
, flags
);
677 /* Feature supported, correct order can be used */
678 ret
= conn
->networkDriver
->networkUpdate(network
, command
, section
,
679 parentIndex
, xml
, flags
);
687 virReportUnsupportedError();
690 virDispatchError(network
->conn
);
697 * @network: pointer to a defined network
699 * Create and start a defined network. If the call succeed the network
700 * moves from the defined to the running networks pools.
702 * Returns 0 in case of success, -1 in case of error
707 virNetworkCreate(virNetworkPtr network
)
710 VIR_DEBUG("network=%p", network
);
714 virCheckNetworkReturn(network
, -1);
715 conn
= network
->conn
;
717 virCheckReadOnlyGoto(conn
->flags
, error
);
719 if (conn
->networkDriver
&& conn
->networkDriver
->networkCreate
) {
721 ret
= conn
->networkDriver
->networkCreate(network
);
727 virReportUnsupportedError();
730 virDispatchError(network
->conn
);
737 * @network: a network object
739 * Destroy the network object. The running instance is shutdown if not down
740 * already and all resources used by it are given back to the hypervisor. This
741 * does not free the associated virNetworkPtr object.
742 * This function may require privileged access
744 * Returns 0 in case of success and -1 in case of failure.
749 virNetworkDestroy(virNetworkPtr network
)
752 VIR_DEBUG("network=%p", network
);
756 virCheckNetworkReturn(network
, -1);
757 conn
= network
->conn
;
759 virCheckReadOnlyGoto(conn
->flags
, error
);
761 if (conn
->networkDriver
&& conn
->networkDriver
->networkDestroy
) {
763 ret
= conn
->networkDriver
->networkDestroy(network
);
769 virReportUnsupportedError();
772 virDispatchError(network
->conn
);
779 * @network: a network object
781 * Free the network object. The running instance is kept alive.
782 * The data structure is freed and should not be used thereafter.
784 * Returns 0 in case of success and -1 in case of failure.
789 virNetworkFree(virNetworkPtr network
)
791 VIR_DEBUG("network=%p", network
);
795 virCheckNetworkReturn(network
, -1);
797 virObjectUnref(network
);
804 * @network: the network to hold a reference on
806 * Increment the reference count on the network. For each
807 * additional call to this method, there shall be a corresponding
808 * call to virNetworkFree to release the reference count, once
809 * the caller no longer needs the reference to this object.
811 * This method is typically useful for applications where multiple
812 * threads are using a connection, and it is required that the
813 * connection remain open until all threads have finished using
814 * it. ie, each new thread using a network would increment
815 * the reference count.
817 * Returns 0 in case of success, -1 in case of failure.
822 virNetworkRef(virNetworkPtr network
)
824 VIR_DEBUG("network=%p", network
);
828 virCheckNetworkReturn(network
, -1);
830 virObjectRef(network
);
837 * @network: a network object
839 * Get the public name for that network
841 * Returns a pointer to the name or NULL, the string need not be deallocated
842 * its lifetime will be the same as the network object.
847 virNetworkGetName(virNetworkPtr network
)
849 VIR_DEBUG("network=%p", network
);
853 virCheckNetworkReturn(network
, NULL
);
855 return network
->name
;
861 * @network: a network object
862 * @uuid: pointer to a VIR_UUID_BUFLEN bytes array
864 * Get the UUID for a network
866 * Returns -1 in case of error, 0 in case of success
871 virNetworkGetUUID(virNetworkPtr network
, unsigned char *uuid
)
873 VIR_DEBUG("network=%p, uuid=%p", network
, uuid
);
877 virCheckNetworkReturn(network
, -1);
878 virCheckNonNullArgGoto(uuid
, error
);
880 memcpy(uuid
, &network
->uuid
[0], VIR_UUID_BUFLEN
);
885 virDispatchError(network
->conn
);
891 * virNetworkGetUUIDString:
892 * @network: a network object
893 * @buf: pointer to a VIR_UUID_STRING_BUFLEN bytes array
895 * Get the UUID for a network as string. For more information about
898 * Returns -1 in case of error, 0 in case of success
903 virNetworkGetUUIDString(virNetworkPtr network
, char *buf
)
905 VIR_DEBUG("network=%p, buf=%p", network
, buf
);
909 virCheckNetworkReturn(network
, -1);
910 virCheckNonNullArgGoto(buf
, error
);
912 virUUIDFormat(network
->uuid
, buf
);
916 virDispatchError(network
->conn
);
922 * virNetworkGetXMLDesc:
923 * @network: a network object
924 * @flags: bitwise-OR of virNetworkXMLFlags
926 * Provide an XML description of the network. The description may be reused
927 * later to relaunch the network with virNetworkCreateXML().
929 * Normally, if a network included a physical function, the output includes
930 * all virtual functions tied to that physical interface. If @flags includes
931 * VIR_NETWORK_XML_INACTIVE, then the expansion of virtual interfaces is
934 * Returns a 0 terminated UTF-8 encoded XML instance, or NULL in case
935 * of error. The caller must free() the returned value.
940 virNetworkGetXMLDesc(virNetworkPtr network
, unsigned int flags
)
943 VIR_DEBUG("network=%p, flags=0x%x", network
, flags
);
947 virCheckNetworkReturn(network
, NULL
);
948 conn
= network
->conn
;
950 if (conn
->networkDriver
&& conn
->networkDriver
->networkGetXMLDesc
) {
952 ret
= conn
->networkDriver
->networkGetXMLDesc(network
, flags
);
958 virReportUnsupportedError();
961 virDispatchError(network
->conn
);
967 * virNetworkGetBridgeName:
968 * @network: a network object
970 * Provides a bridge interface name to which a domain may connect
971 * a network interface in order to join the network.
973 * Returns a 0 terminated interface name, or NULL in case of
974 * error. The caller must free() the returned value.
979 virNetworkGetBridgeName(virNetworkPtr network
)
982 VIR_DEBUG("network=%p", network
);
986 virCheckNetworkReturn(network
, NULL
);
987 conn
= network
->conn
;
989 if (conn
->networkDriver
&& conn
->networkDriver
->networkGetBridgeName
) {
991 ret
= conn
->networkDriver
->networkGetBridgeName(network
);
997 virReportUnsupportedError();
1000 virDispatchError(network
->conn
);
1006 * virNetworkGetAutostart:
1007 * @network: a network object
1008 * @autostart: the value returned
1010 * Provides a boolean value indicating whether the network
1011 * configured to be automatically started when the host
1014 * Returns -1 in case of error, 0 in case of success
1019 virNetworkGetAutostart(virNetworkPtr network
,
1023 VIR_DEBUG("network=%p, autostart=%p", network
, autostart
);
1025 virResetLastError();
1027 virCheckNetworkReturn(network
, -1);
1028 virCheckNonNullArgGoto(autostart
, error
);
1030 conn
= network
->conn
;
1032 if (conn
->networkDriver
&& conn
->networkDriver
->networkGetAutostart
) {
1034 ret
= conn
->networkDriver
->networkGetAutostart(network
, autostart
);
1040 virReportUnsupportedError();
1043 virDispatchError(network
->conn
);
1049 * virNetworkSetAutostart:
1050 * @network: a network object
1051 * @autostart: whether the network should be automatically started 0 or 1
1053 * Configure the network to be automatically started
1054 * when the host machine boots.
1056 * Returns -1 in case of error, 0 in case of success
1061 virNetworkSetAutostart(virNetworkPtr network
,
1065 VIR_DEBUG("network=%p, autostart=%d", network
, autostart
);
1067 virResetLastError();
1069 virCheckNetworkReturn(network
, -1);
1070 conn
= network
->conn
;
1072 virCheckReadOnlyGoto(conn
->flags
, error
);
1074 if (conn
->networkDriver
&& conn
->networkDriver
->networkSetAutostart
) {
1076 ret
= conn
->networkDriver
->networkSetAutostart(network
, autostart
);
1082 virReportUnsupportedError();
1085 virDispatchError(network
->conn
);
1091 * virNetworkIsActive:
1092 * @net: pointer to the network object
1094 * Determine if the network is currently running
1096 * Returns 1 if running, 0 if inactive, -1 on error
1101 virNetworkIsActive(virNetworkPtr net
)
1103 VIR_DEBUG("net=%p", net
);
1105 virResetLastError();
1107 virCheckNetworkReturn(net
, -1);
1109 if (net
->conn
->networkDriver
->networkIsActive
) {
1111 ret
= net
->conn
->networkDriver
->networkIsActive(net
);
1117 virReportUnsupportedError();
1119 virDispatchError(net
->conn
);
1125 * virNetworkIsPersistent:
1126 * @net: pointer to the network object
1128 * Determine if the network has a persistent configuration
1129 * which means it will still exist after shutting down
1131 * Returns 1 if persistent, 0 if transient, -1 on error
1136 virNetworkIsPersistent(virNetworkPtr net
)
1138 VIR_DEBUG("net=%p", net
);
1140 virResetLastError();
1142 virCheckNetworkReturn(net
, -1);
1144 if (net
->conn
->networkDriver
->networkIsPersistent
) {
1146 ret
= net
->conn
->networkDriver
->networkIsPersistent(net
);
1152 virReportUnsupportedError();
1154 virDispatchError(net
->conn
);
1160 * virConnectNetworkEventRegisterAny:
1161 * @conn: pointer to the connection
1162 * @net: pointer to the network
1163 * @eventID: the event type to receive
1164 * @cb: callback to the function handling network events
1165 * @opaque: opaque data to pass on to the callback
1166 * @freecb: optional function to deallocate opaque when not used anymore
1168 * Adds a callback to receive notifications of arbitrary network events
1169 * occurring on a network. This function requires that an event loop
1170 * has been previously registered with virEventRegisterImpl() or
1171 * virEventRegisterDefaultImpl().
1173 * If @net is NULL, then events will be monitored for any network. If @net
1174 * is non-NULL, then only the specific network will be monitored.
1176 * Most types of event have a callback providing a custom set of parameters
1177 * for the event. When registering an event, it is thus necessary to use
1178 * the VIR_NETWORK_EVENT_CALLBACK() macro to cast the supplied function pointer
1179 * to match the signature of this method.
1181 * The virNetworkPtr object handle passed into the callback upon delivery
1182 * of an event is only valid for the duration of execution of the callback.
1183 * If the callback wishes to keep the network object after the callback
1184 * returns, it shall take a reference to it, by calling virNetworkRef().
1185 * The reference can be released once the object is no longer required
1186 * by calling virNetworkFree().
1188 * The return value from this method is a positive integer identifier
1189 * for the callback. To unregister a callback, this callback ID should
1190 * be passed to the virConnectNetworkEventDeregisterAny() method.
1192 * Returns a callback identifier on success, -1 on failure.
1197 virConnectNetworkEventRegisterAny(virConnectPtr conn
,
1200 virConnectNetworkEventGenericCallback cb
,
1202 virFreeCallback freecb
)
1204 VIR_DEBUG("conn=%p, eventID=%d, cb=%p, opaque=%p, freecb=%p",
1205 conn
, eventID
, cb
, opaque
, freecb
);
1207 virResetLastError();
1209 virCheckConnectReturn(conn
, -1);
1211 virCheckNetworkGoto(net
, error
);
1212 if (net
->conn
!= conn
) {
1213 virReportInvalidArg(net
,
1214 _("network '%1$s' in %2$s must match connection"),
1215 net
->name
, __FUNCTION__
);
1219 virCheckNonNullArgGoto(cb
, error
);
1220 virCheckNonNegativeArgGoto(eventID
, error
);
1222 if (eventID
>= VIR_NETWORK_EVENT_ID_LAST
) {
1223 virReportInvalidArg(eventID
,
1224 _("eventID in %1$s must be less than %2$d"),
1225 __FUNCTION__
, VIR_NETWORK_EVENT_ID_LAST
);
1229 if (conn
->networkDriver
&& conn
->networkDriver
->connectNetworkEventRegisterAny
) {
1231 ret
= conn
->networkDriver
->connectNetworkEventRegisterAny(conn
, net
,
1240 virReportUnsupportedError();
1242 virDispatchError(conn
);
1248 * virConnectNetworkEventDeregisterAny:
1249 * @conn: pointer to the connection
1250 * @callbackID: the callback identifier
1252 * Removes an event callback. The callbackID parameter should be the
1253 * value obtained from a previous virConnectNetworkEventRegisterAny() method.
1255 * Returns 0 on success, -1 on failure
1260 virConnectNetworkEventDeregisterAny(virConnectPtr conn
,
1263 VIR_DEBUG("conn=%p, callbackID=%d", conn
, callbackID
);
1265 virResetLastError();
1267 virCheckConnectReturn(conn
, -1);
1268 virCheckNonNegativeArgGoto(callbackID
, error
);
1270 if (conn
->networkDriver
&&
1271 conn
->networkDriver
->connectNetworkEventDeregisterAny
) {
1273 ret
= conn
->networkDriver
->connectNetworkEventDeregisterAny(conn
,
1280 virReportUnsupportedError();
1282 virDispatchError(conn
);
1288 * virNetworkGetDHCPLeases:
1289 * @network: Pointer to network object
1290 * @mac: Optional ASCII formatted MAC address of an interface
1291 * @leases: Pointer to a variable to store the array containing details on
1292 * obtained leases, or NULL if the list is not required (just returns
1293 * number of leases).
1294 * @flags: Extra flags, not used yet, so callers should always pass 0
1296 * For DHCPv4, the information returned:
1297 * - Network Interface Name
1301 * - IPv4 address (with type and prefix)
1302 * - Hostname (can be NULL)
1303 * - Client ID (can be NULL)
1305 * For DHCPv6, the information returned:
1306 * - Network Interface Name
1309 * - IAID (can be NULL, only in rare cases)
1310 * - IPv6 address (with type and prefix)
1311 * - Hostname (can be NULL)
1314 * Note: @mac, @iaid, @ipaddr, @clientid are in ASCII form, not raw bytes.
1315 * Note: @expirytime can 0, in case the lease is for infinite time.
1317 * The API fetches leases info of guests in the specified network. If the
1318 * optional parameter @mac is specified, the returned list will contain only
1319 * lease info about a specific guest interface with @mac. There can be
1320 * multiple leases for a single @mac because this API supports DHCPv6 too.
1322 * On success, the array stored into @leases is guaranteed to
1323 * have an extra allocated element set to NULL but not included in the return
1324 * count, to make iteration easier. The caller is responsible for calling
1325 * virNetworkDHCPLeaseFree() on each array element, then calling free() on @leases.
1327 * See also virNetworkGetDHCPLeasesForMAC() as a convenience for filtering
1328 * the list to a single MAC address.
1332 * virNetworkDHCPLeasePtr *leases = NULL;
1333 * virNetworkPtr network = ... obtain a network pointer here ...;
1336 * unsigned int flags = 0;
1338 * nleases = virNetworkGetDHCPLeases(network, NULL, &leases, flags);
1342 * ... do something with returned values, for example:
1344 * for (i = 0; i < nleases; i++) {
1345 * virNetworkDHCPLeasePtr lease = leases[i];
1347 * printf("Time(epoch): %lu, MAC address: %s, "
1348 * "IP address: %s, Hostname: %s, ClientID: %s\n",
1349 * lease->expirytime, lease->mac, lease->ipaddr,
1350 * lease->hostname, lease->clientid);
1352 * virNetworkDHCPLeaseFree(leases[i]);
1357 * Returns the number of leases found or -1 and sets @leases to NULL in
1363 virNetworkGetDHCPLeases(virNetworkPtr network
,
1365 virNetworkDHCPLeasePtr
**leases
,
1369 VIR_DEBUG("network=%p, mac='%s' leases=%p, flags=0x%x",
1370 network
, NULLSTR(mac
), leases
, flags
);
1372 virResetLastError();
1377 virCheckNetworkReturn(network
, -1);
1379 conn
= network
->conn
;
1381 if (conn
->networkDriver
&& conn
->networkDriver
->networkGetDHCPLeases
) {
1383 ret
= conn
->networkDriver
->networkGetDHCPLeases(network
, mac
, leases
, flags
);
1389 virReportUnsupportedError();
1392 virDispatchError(network
->conn
);
1398 * virNetworkDHCPLeaseFree:
1399 * @lease: pointer to a leases object
1401 * Frees all the memory occupied by @lease.
1406 virNetworkDHCPLeaseFree(virNetworkDHCPLeasePtr lease
)
1410 g_free(lease
->iface
);
1412 g_free(lease
->iaid
);
1413 g_free(lease
->ipaddr
);
1414 g_free(lease
->hostname
);
1415 g_free(lease
->clientid
);
1421 * virNetworkPortLookupByUUID:
1422 * @net: pointer to the network object
1423 * @uuid: the raw UUID for the network port
1425 * Try to lookup a port on the given network based on its UUID.
1427 * virNetworkPortFree should be used to free the resources after the
1428 * network port object is no longer needed.
1430 * Returns a new network port object or NULL in case of failure. If the
1431 * network port cannot be found, then VIR_ERR_NO_NETWORK_PORT error is raised.
1436 virNetworkPortLookupByUUID(virNetworkPtr net
,
1437 const unsigned char *uuid
)
1439 VIR_UUID_DEBUG(net
, uuid
);
1441 virResetLastError();
1443 virCheckNetworkReturn(net
, NULL
);
1444 virCheckNonNullArgGoto(uuid
, error
);
1446 if (net
->conn
->networkDriver
&& net
->conn
->networkDriver
->networkPortLookupByUUID
) {
1447 virNetworkPortPtr ret
;
1448 ret
= net
->conn
->networkDriver
->networkPortLookupByUUID(net
, uuid
);
1454 virReportUnsupportedError();
1457 virDispatchError(net
->conn
);
1463 * virNetworkPortLookupByUUIDString:
1464 * @net: pointer to the network object
1465 * @uuidstr: the string UUID for the port
1467 * Try to lookup a port on the given network based on its UUID.
1469 * Returns a new network port object or NULL in case of failure. If the
1470 * network port cannot be found, then VIR_ERR_NO_NETWORK_PORT error is raised.
1475 virNetworkPortLookupByUUIDString(virNetworkPtr net
,
1476 const char *uuidstr
)
1478 unsigned char uuid
[VIR_UUID_BUFLEN
];
1479 VIR_DEBUG("net=%p, uuidstr=%s", net
, NULLSTR(uuidstr
));
1481 virResetLastError();
1483 virCheckNetworkReturn(net
, NULL
);
1484 virCheckNonNullArgGoto(uuidstr
, error
);
1486 if (virUUIDParse(uuidstr
, uuid
) < 0) {
1487 virReportInvalidArg(uuidstr
,
1488 _("uuidstr in %1$s must be a valid UUID"),
1493 return virNetworkPortLookupByUUID(net
, &uuid
[0]);
1496 virDispatchError(net
->conn
);
1502 * virNetworkPortSetParameters:
1503 * @port: a network port object
1504 * @params: pointer to interface parameter objects
1505 * @nparams: number of interface parameter (this value can be the same or
1506 * less than the number of parameters supported)
1507 * @flags: currently unused, pass 0
1509 * Change a subset or all parameters of the network port; currently this
1510 * includes bandwidth parameters.
1512 * Returns -1 in case of error, 0 in case of success.
1517 virNetworkPortSetParameters(virNetworkPortPtr port
,
1518 virTypedParameterPtr params
,
1523 VIR_DEBUG("port=%p, params=%p, nparams=%d, flags=0x%x", port
, params
, nparams
, flags
);
1524 VIR_TYPED_PARAMS_DEBUG(params
, nparams
);
1526 virResetLastError();
1528 virCheckNetworkPortReturn(port
, -1);
1529 conn
= port
->net
->conn
;
1531 virCheckReadOnlyGoto(conn
->flags
, error
);
1533 if (conn
->networkDriver
&& conn
->networkDriver
->networkPortSetParameters
) {
1535 ret
= conn
->networkDriver
->networkPortSetParameters(port
, params
, nparams
, flags
);
1541 virReportUnsupportedError();
1544 virDispatchError(conn
);
1550 * virNetworkPortGetParameters:
1551 * @port: a network port object
1552 * @params: pointer to pointer of interface parameter objects
1553 * @nparams: pointer to received number of interface parameter
1554 * @flags: currently unused, pass 0
1556 * Get all interface parameters. On input, @params should be initialized
1557 * to NULL. On return @params will be allocated with the size large
1558 * enough to hold all parameters, and @nparams will be updated to say
1559 * how many parameters are present. @params should be freed by the caller
1562 * Returns -1 in case of error, 0 in case of success.
1567 virNetworkPortGetParameters(virNetworkPortPtr port
,
1568 virTypedParameterPtr
*params
,
1573 VIR_DEBUG("port=%p, params=%p, nparams=%p, flags=0x%x", port
, params
, nparams
, flags
);
1575 virResetLastError();
1577 virCheckNetworkPortReturn(port
, -1);
1578 conn
= port
->net
->conn
;
1580 virCheckNonNullArgGoto(nparams
, error
);
1581 virCheckNonNegativeArgGoto(*nparams
, error
);
1583 if (conn
->networkDriver
&& conn
->networkDriver
->networkPortGetParameters
) {
1585 ret
= conn
->networkDriver
->networkPortGetParameters(port
, params
, nparams
, flags
);
1591 virReportUnsupportedError();
1594 virDispatchError(conn
);
1600 * virNetworkPortCreateXML:
1601 * @net: pointer to the network object
1602 * @xmldesc: an XML description of the port
1603 * @flags: bitwise-OR of virNetworkPortCreateFlags
1605 * Create a new network port, based on an XML description
1606 * similar to the one returned by virNetworkPortGetXMLDesc()
1608 * virNetworkPortFree should be used to free the resources after the
1609 * network port object is no longer needed.
1611 * Returns a new network port object or NULL in case of failure
1616 virNetworkPortCreateXML(virNetworkPtr net
,
1617 const char *xmldesc
,
1620 VIR_DEBUG("net=%p, xmldesc=%s, flags=0x%x", net
, NULLSTR(xmldesc
), flags
);
1622 virResetLastError();
1624 virCheckNetworkReturn(net
, NULL
);
1625 virCheckNonNullArgGoto(xmldesc
, error
);
1626 virCheckReadOnlyGoto(net
->conn
->flags
, error
);
1628 if (net
->conn
->networkDriver
&& net
->conn
->networkDriver
->networkPortCreateXML
) {
1629 virNetworkPortPtr ret
;
1630 ret
= net
->conn
->networkDriver
->networkPortCreateXML(net
, xmldesc
, flags
);
1636 virReportUnsupportedError();
1639 virDispatchError(net
->conn
);
1644 * virNetworkPortGetNetwork:
1645 * @port: pointer to a network port
1647 * Provides the network pointer associated with a port. The
1648 * reference counter on the connection is not increased by this
1651 * Returns the virNetworkPtr or NULL in case of failure.
1656 virNetworkPortGetNetwork(virNetworkPortPtr port
)
1658 VIR_DEBUG("port=%p", port
);
1660 virResetLastError();
1662 virCheckNetworkPortReturn(port
, NULL
);
1669 * virNetworkPortGetXMLDesc:
1670 * @port: a network port object
1671 * @flags: currently unused, pass 0
1673 * Provide an XML description of the network port. The description may be reused
1674 * later to recreate the port with virNetworkPortCreateXML().
1676 * Returns a 0 terminated UTF-8 encoded XML instance, or NULL in case of error.
1677 * the caller must free() the returned value.
1682 virNetworkPortGetXMLDesc(virNetworkPortPtr port
,
1686 VIR_DEBUG("port=%p, flags=0x%x", port
, flags
);
1688 virResetLastError();
1690 virCheckNetworkPortReturn(port
, NULL
);
1691 conn
= port
->net
->conn
;
1693 if (conn
->networkDriver
&& conn
->networkDriver
->networkPortGetXMLDesc
) {
1695 ret
= conn
->networkDriver
->networkPortGetXMLDesc(port
, flags
);
1701 virReportUnsupportedError();
1704 virDispatchError(conn
);
1710 * virNetworkPortGetUUID:
1711 * @port: a network port object
1712 * @uuid: pointer to a VIR_UUID_BUFLEN bytes array
1714 * Get the UUID for a network port
1716 * Returns -1 in case of error, 0 in case of success
1721 virNetworkPortGetUUID(virNetworkPortPtr port
,
1722 unsigned char *uuid
)
1724 VIR_DEBUG("port=%p, uuid=%p", port
, uuid
);
1726 virResetLastError();
1728 virCheckNetworkPortReturn(port
, -1);
1729 virCheckNonNullArgGoto(uuid
, error
);
1731 memcpy(uuid
, &port
->uuid
[0], VIR_UUID_BUFLEN
);
1736 virDispatchError(port
->net
->conn
);
1742 * virNetworkPortGetUUIDString:
1743 * @port: a network port object
1744 * @buf: pointer to a VIR_UUID_STRING_BUFLEN bytes array
1746 * Get the UUID for a network as string. For more information about
1749 * Returns -1 in case of error, 0 in case of success
1754 virNetworkPortGetUUIDString(virNetworkPortPtr port
,
1757 VIR_DEBUG("port=%p, buf=%p", port
, buf
);
1759 virResetLastError();
1761 virCheckNetworkPortReturn(port
, -1);
1762 virCheckNonNullArgGoto(buf
, error
);
1764 virUUIDFormat(port
->uuid
, buf
);
1768 virDispatchError(port
->net
->conn
);
1773 * virNetworkPortDelete:
1774 * @port: a port object
1775 * @flags: currently unused, pass 0
1777 * Delete the network port. This does not free the
1778 * associated virNetworkPortPtr object. It is the
1779 * caller's responsibility to ensure the port is not
1780 * still in use by a virtual machine before deleting
1783 * Returns 0 in case of success and -1 in case of failure.
1788 virNetworkPortDelete(virNetworkPortPtr port
,
1792 VIR_DEBUG("port=%p, flags=0x%x", port
, flags
);
1794 virResetLastError();
1796 virCheckNetworkPortReturn(port
, -1);
1797 conn
= port
->net
->conn
;
1799 virCheckReadOnlyGoto(conn
->flags
, error
);
1801 if (conn
->networkDriver
&& conn
->networkDriver
->networkPortDelete
) {
1803 ret
= conn
->networkDriver
->networkPortDelete(port
, flags
);
1809 virReportUnsupportedError();
1812 virDispatchError(conn
);
1818 * virNetworkListAllPorts:
1819 * @network: pointer to a network object
1820 * @ports: Pointer to a variable to store the array containing network port
1821 * objects or NULL if the list is not required (just returns number
1823 * @flags: extra flags; not used yet, so callers should always pass 0
1825 * Collect the list of network ports, and allocate an array to store those
1828 * Returns the number of network ports found or -1 and sets @ports to
1829 * NULL in case of error. On success, the array stored into @ports is
1830 * guaranteed to have an extra allocated element set to NULL but not included
1831 * in the return count, to make iteration easier. The caller is responsible
1832 * for calling virNetworkPortFree() on each array element, then calling
1838 virNetworkListAllPorts(virNetworkPtr network
,
1839 virNetworkPortPtr
**ports
,
1842 VIR_DEBUG("network=%p, ports=%p, flags=0x%x", network
, ports
, flags
);
1844 virResetLastError();
1846 virCheckNetworkReturn(network
, -1);
1848 if (network
->conn
->networkDriver
&&
1849 network
->conn
->networkDriver
->networkListAllPorts
) {
1851 ret
= network
->conn
->networkDriver
->networkListAllPorts(network
, ports
, flags
);
1857 virReportUnsupportedError();
1860 virDispatchError(network
->conn
);
1866 * virNetworkPortFree:
1867 * @port: a network port object
1869 * Free the network port object.
1870 * The data structure is freed and should not be used thereafter.
1872 * Returns 0 in case of success and -1 in case of failure.
1877 virNetworkPortFree(virNetworkPortPtr port
)
1879 VIR_DEBUG("port=%p", port
);
1881 virResetLastError();
1883 virCheckNetworkPortReturn(port
, -1);
1885 virObjectUnref(port
);
1891 * virNetworkPortRef:
1892 * @port: a network port object
1894 * Increment the reference count on the network port. For each
1895 * additional call to this method, there shall be a corresponding
1896 * call to virNetworkPortFree to release the reference count, once
1897 * the caller no longer needs the reference to this object.
1899 * This method is typically useful for applications where multiple
1900 * threads are using a network port, and it is required that the
1901 * port remain resident until all threads have finished using
1902 * it. ie, each new thread using a network port would increment
1903 * the reference count.
1905 * Returns 0 in case of success, -1 in case of failure.
1910 virNetworkPortRef(virNetworkPortPtr port
)
1912 VIR_DEBUG("port=%p", port
);
1914 virResetLastError();
1916 virCheckNetworkPortReturn(port
, -1);
1924 * virNetworkSetMetadata:
1925 * @network: a network object
1926 * @type: type of metadata, from virNetworkMetadataType
1927 * @metadata: new metadata text
1928 * @key: XML namespace key, or NULL
1929 * @uri: XML namespace URI, or NULL
1930 * @flags: bitwise-OR of virNetworkUpdateFlags
1932 * Sets the appropriate network element given by @type to the
1933 * value of @metadata. A @type of VIR_NETWORK_METADATA_DESCRIPTION
1934 * is free-form text; VIR_NETWORK_METADATA_TITLE is free-form, but no
1935 * newlines are permitted, and should be short (although the length is
1936 * not enforced). For these two options @key and @uri are irrelevant and
1937 * must be set to NULL.
1939 * For type VIR_NETWORK_METADATA_ELEMENT @metadata must be well-formed
1940 * XML belonging to namespace defined by @uri with local name @key.
1942 * Passing NULL for @metadata says to remove that element from the
1943 * network XML (passing the empty string leaves the element present).
1945 * The resulting metadata will be present in virNetworkGetXMLDesc(),
1946 * as well as quick access through virNetworkGetMetadata().
1948 * @flags controls whether the live network state, persistent configuration,
1949 * or both will be modified.
1951 * Returns 0 on success, -1 in case of failure.
1956 virNetworkSetMetadata(virNetworkPtr network
,
1958 const char *metadata
,
1965 VIR_DEBUG("network=%p, type=%d, metadata='%s', key='%s', uri='%s', flags=0x%x",
1966 network
, type
, NULLSTR(metadata
), NULLSTR(key
), NULLSTR(uri
),
1969 virResetLastError();
1971 virCheckNetworkReturn(network
, -1);
1972 conn
= network
->conn
;
1974 virCheckReadOnlyGoto(conn
->flags
, error
);
1977 case VIR_NETWORK_METADATA_TITLE
:
1978 if (metadata
&& strchr(metadata
, '\n')) {
1979 virReportInvalidArg(metadata
, "%s",
1980 _("metadata title can't contain newlines"));
1984 case VIR_NETWORK_METADATA_DESCRIPTION
:
1985 virCheckNullArgGoto(uri
, error
);
1986 virCheckNullArgGoto(key
, error
);
1988 case VIR_NETWORK_METADATA_ELEMENT
:
1989 virCheckNonNullArgGoto(uri
, error
);
1991 virCheckNonNullArgGoto(key
, error
);
1994 /* For future expansion */
1998 if (conn
->networkDriver
->networkSetMetadata
) {
2000 ret
= conn
->networkDriver
->networkSetMetadata(network
, type
, metadata
, key
, uri
,
2007 virReportUnsupportedError();
2010 virDispatchError(network
->conn
);
2016 * virNetworkGetMetadata:
2017 * @network: a network object
2018 * @type: type of metadata, from virNetworkMetadataType
2019 * @uri: XML namespace identifier
2020 * @flags: bitwise-OR of virNetworkUpdateFlags
2022 * Retrieves the appropriate network element given by @type.
2023 * If VIR_NETWORK_METADATA_ELEMENT is requested parameter @uri
2024 * must be set to the name of the namespace the requested elements
2025 * belong to, otherwise must be NULL.
2027 * If an element of the network XML is not present, the resulting
2028 * error will be VIR_ERR_NO_NETWORK_METADATA. This method forms
2029 * a shortcut for seeing information from virNetworkSetMetadata()
2030 * without having to go through virNetworkGetXMLDesc().
2032 * @flags controls whether the live network state or persistent
2033 * configuration will be queried.
2035 * Returns the metadata string on success (caller must free),
2036 * or NULL in case of failure.
2041 virNetworkGetMetadata(virNetworkPtr network
,
2048 VIR_DEBUG("network=%p, type=%d, uri='%s', flags=0x%x",
2049 network
, type
, NULLSTR(uri
), flags
);
2051 virResetLastError();
2053 virCheckNetworkReturn(network
, NULL
);
2055 VIR_EXCLUSIVE_FLAGS_GOTO(VIR_NETWORK_UPDATE_AFFECT_LIVE
,
2056 VIR_NETWORK_UPDATE_AFFECT_CONFIG
,
2060 case VIR_NETWORK_METADATA_TITLE
:
2061 case VIR_NETWORK_METADATA_DESCRIPTION
:
2062 virCheckNullArgGoto(uri
, error
);
2064 case VIR_NETWORK_METADATA_ELEMENT
:
2065 virCheckNonNullArgGoto(uri
, error
);
2068 /* For future expansion */
2072 conn
= network
->conn
;
2074 if (conn
->networkDriver
->networkGetMetadata
) {
2076 if (!(ret
= conn
->networkDriver
->networkGetMetadata(network
, type
, uri
, flags
)))
2081 virReportUnsupportedError();
2084 virDispatchError(network
->conn
);