Advertisement
Guest User

Untitled

a guest
Sep 29th, 2015
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 276.67 KB | None | 0 0
  1. #
  2. # WARNING WARNING WARNING WARNING
  3. #
  4. # This file is automatically written by generator.py. Any changes
  5. # made here will be lost.
  6. #
  7. # To change the manually written methods edit libvirt-override.py
  8. # To change the automatically written methods edit generator.py
  9. #
  10. # WARNING WARNING WARNING WARNING
  11. #
  12. #
  13. # Manually written part of python bindings for libvirt
  14. #
  15.  
  16. # On cygwin, the DLL is called cygvirtmod.dll
  17. import sys
  18.  
  19. try:
  20. import libvirtmod
  21. except ImportError:
  22. lib_e = sys.exc_info()[1]
  23. try:
  24. import cygvirtmod as libvirtmod
  25. except ImportError:
  26. cyg_e = sys.exc_info()[1]
  27. if str(cyg_e).count("No module named"):
  28. raise lib_e
  29.  
  30. import types
  31.  
  32. # The root of all libvirt errors.
  33. class libvirtError(Exception):
  34. def __init__(self, defmsg, conn=None, dom=None, net=None, pool=None, vol=None):
  35.  
  36. # Never call virConnGetLastError().
  37. # virGetLastError() is now thread local
  38. err = libvirtmod.virGetLastError()
  39. if err is None:
  40. msg = defmsg
  41. else:
  42. msg = err[2]
  43.  
  44. Exception.__init__(self, msg)
  45.  
  46. self.err = err
  47.  
  48. def get_error_code(self):
  49. if self.err is None:
  50. return None
  51. return self.err[0]
  52.  
  53. def get_error_domain(self):
  54. if self.err is None:
  55. return None
  56. return self.err[1]
  57.  
  58. def get_error_message(self):
  59. if self.err is None:
  60. return None
  61. return self.err[2]
  62.  
  63. def get_error_level(self):
  64. if self.err is None:
  65. return None
  66. return self.err[3]
  67.  
  68. def get_str1(self):
  69. if self.err is None:
  70. return None
  71. return self.err[4]
  72.  
  73. def get_str2(self):
  74. if self.err is None:
  75. return None
  76. return self.err[5]
  77.  
  78. def get_str3(self):
  79. if self.err is None:
  80. return None
  81. return self.err[6]
  82.  
  83. def get_int1(self):
  84. if self.err is None:
  85. return None
  86. return self.err[7]
  87.  
  88. def get_int2(self):
  89. if self.err is None:
  90. return None
  91. return self.err[8]
  92.  
  93. #
  94. # register the libvirt global error handler
  95. #
  96. def registerErrorHandler(f, ctx):
  97. """Register a Python function for error reporting.
  98. The function is called back as f(ctx, error), with error
  99. being a list of information about the error being raised.
  100. Returns 1 in case of success."""
  101. return libvirtmod.virRegisterErrorHandler(f,ctx)
  102.  
  103. def openAuth(uri, auth, flags=0):
  104. ret = libvirtmod.virConnectOpenAuth(uri, auth, flags)
  105. if ret is None:raise libvirtError('virConnectOpenAuth() failed')
  106. return virConnect(_obj=ret)
  107.  
  108.  
  109. #
  110. # Return library version.
  111. #
  112. def getVersion (name = None):
  113. """If no name parameter is passed (or name is None) then the
  114. version of the libvirt library is returned as an integer.
  115.  
  116. If a name is passed and it refers to a driver linked to the
  117. libvirt library, then this returns a tuple of (library version,
  118. driver version).
  119.  
  120. If the name passed refers to a non-existent driver, then you
  121. will get the exception 'no support for hypervisor'.
  122.  
  123. Versions numbers are integers: 1000000*major + 1000*minor + release."""
  124. if name is None:
  125. ret = libvirtmod.virGetVersion ()
  126. else:
  127. ret = libvirtmod.virGetVersion (name)
  128. if ret is None: raise libvirtError ("virGetVersion() failed")
  129. return ret
  130.  
  131.  
  132. #
  133. # Invoke an EventHandle callback
  134. #
  135. def _eventInvokeHandleCallback(watch, fd, event, opaque, opaquecompat=None):
  136. """
  137. Invoke the Event Impl Handle Callback in C
  138. """
  139. # libvirt 0.9.2 and earlier required custom event loops to know
  140. # that opaque=(cb, original_opaque) and pass the values individually
  141. # to this wrapper. This should handle the back compat case, and make
  142. # future invocations match the virEventHandleCallback prototype
  143. if opaquecompat:
  144. callback = opaque
  145. opaque = opaquecompat
  146. else:
  147. callback = opaque[0]
  148. opaque = opaque[1]
  149.  
  150. libvirtmod.virEventInvokeHandleCallback(watch, fd, event, callback, opaque)
  151.  
  152. #
  153. # Invoke an EventTimeout callback
  154. #
  155. def _eventInvokeTimeoutCallback(timer, opaque, opaquecompat=None):
  156. """
  157. Invoke the Event Impl Timeout Callback in C
  158. """
  159. # libvirt 0.9.2 and earlier required custom event loops to know
  160. # that opaque=(cb, original_opaque) and pass the values individually
  161. # to this wrapper. This should handle the back compat case, and make
  162. # future invocations match the virEventTimeoutCallback prototype
  163. if opaquecompat:
  164. callback = opaque
  165. opaque = opaquecompat
  166. else:
  167. callback = opaque[0]
  168. opaque = opaque[1]
  169.  
  170. libvirtmod.virEventInvokeTimeoutCallback(timer, callback, opaque)
  171.  
  172. def _dispatchEventHandleCallback(watch, fd, events, cbData):
  173. cb = cbData["cb"]
  174. opaque = cbData["opaque"]
  175.  
  176. cb(watch, fd, events, opaque)
  177. return 0
  178.  
  179. def _dispatchEventTimeoutCallback(timer, cbData):
  180. cb = cbData["cb"]
  181. opaque = cbData["opaque"]
  182.  
  183. cb(timer, opaque)
  184. return 0
  185.  
  186. def virEventAddHandle(fd, events, cb, opaque):
  187. """
  188. register a callback for monitoring file handle events
  189.  
  190. @fd: file handle to monitor for events
  191. @events: bitset of events to watch from virEventHandleType constants
  192. @cb: callback to invoke when an event occurs
  193. @opaque: user data to pass to callback
  194.  
  195. Example callback prototype is:
  196. def cb(watch, # int id of the handle
  197. fd, # int file descriptor the event occurred on
  198. events, # int bitmap of events that have occurred
  199. opaque): # opaque data passed to eventAddHandle
  200. """
  201. cbData = {"cb" : cb, "opaque" : opaque}
  202. ret = libvirtmod.virEventAddHandle(fd, events, cbData)
  203. if ret == -1: raise libvirtError ('virEventAddHandle() failed')
  204. return ret
  205.  
  206. def virEventAddTimeout(timeout, cb, opaque):
  207. """
  208. register a callback for a timer event
  209.  
  210. @timeout: time between events in milliseconds
  211. @cb: callback to invoke when an event occurs
  212. @opaque: user data to pass to callback
  213.  
  214. Setting timeout to -1 will disable the timer. Setting the timeout
  215. to zero will cause it to fire on every event loop iteration.
  216.  
  217. Example callback prototype is:
  218. def cb(timer, # int id of the timer
  219. opaque): # opaque data passed to eventAddTimeout
  220. """
  221. cbData = {"cb" : cb, "opaque" : opaque}
  222. ret = libvirtmod.virEventAddTimeout(timeout, cbData)
  223. if ret == -1: raise libvirtError ('virEventAddTimeout() failed')
  224. return ret
  225. #
  226. # WARNING WARNING WARNING WARNING
  227. #
  228. # Automatically written part of python bindings for libvirt
  229. #
  230. # WARNING WARNING WARNING WARNING
  231. #
  232. # Functions from module libvirt
  233. #
  234.  
  235. def open(name=None):
  236. """This function should be called first to get a connection to the
  237. Hypervisor and xen store
  238.  
  239. If @name is None, if the LIBVIRT_DEFAULT_URI environment variable is set,
  240. then it will be used. Otherwise if the client configuration file
  241. has the "uri_default" parameter set, then it will be used. Finally
  242. probing will be done to determine a suitable default driver to activate.
  243. This involves trying each hypervisor in turn until one successfully opens.
  244.  
  245. If connecting to an unprivileged hypervisor driver which requires
  246. the libvirtd daemon to be active, it will automatically be launched
  247. if not already running. This can be prevented by setting the
  248. environment variable LIBVIRT_AUTOSTART=0
  249.  
  250. URIs are documented at http://libvirt.org/uri.html
  251.  
  252. virConnectClose should be used to release the resources after the connection
  253. is no longer needed. """
  254. ret = libvirtmod.virConnectOpen(name)
  255. if ret is None:raise libvirtError('virConnectOpen() failed')
  256. return virConnect(_obj=ret)
  257.  
  258. def openReadOnly(name=None):
  259. """This function should be called first to get a restricted connection to the
  260. library functionalities. The set of APIs usable are then restricted
  261. on the available methods to control the domains.
  262.  
  263. See virConnectOpen for notes about environment variables which can
  264. have an effect on opening drivers and freeing the connection resources
  265.  
  266. URIs are documented at http://libvirt.org/uri.html """
  267. ret = libvirtmod.virConnectOpenReadOnly(name)
  268. if ret is None:raise libvirtError('virConnectOpenReadOnly() failed')
  269. return virConnect(_obj=ret)
  270.  
  271. def virEventRegisterDefaultImpl():
  272. """Registers a default event implementation based on the
  273. poll() system call. This is a generic implementation
  274. that can be used by any client application which does
  275. not have a need to integrate with an external event
  276. loop impl.
  277.  
  278. Once registered, the application has to invoke virEventRunDefaultImpl() in
  279. a loop to process events. Failure to do so may result in connections being
  280. closed unexpectedly as a result of keepalive timeout. The default
  281. event loop fully supports handle and timeout events, but only
  282. wakes up on events registered by libvirt API calls such as
  283. virEventAddHandle() or virConnectDomainEventRegisterAny(). """
  284. ret = libvirtmod.virEventRegisterDefaultImpl()
  285. if ret == -1: raise libvirtError ('virEventRegisterDefaultImpl() failed')
  286. return ret
  287.  
  288. def virEventRegisterImpl(addHandle, updateHandle, removeHandle, addTimeout, updateTimeout, removeTimeout):
  289. """Registers an event implementation, to allow integration
  290. with an external event loop. Applications would use this
  291. to integrate with the libglib2 event loop, or libevent
  292. or the QT event loop.
  293.  
  294. Use of the virEventAddHandle() and similar APIs require that the
  295. corresponding handler is registered. Use of the
  296. virConnectDomainEventRegisterAny() and similar APIs requires that
  297. the three timeout handlers are registered. Likewise, the three
  298. timeout handlers must be registered if the remote server has been
  299. configured to send keepalive messages, or if the client intends
  300. to call virConnectSetKeepAlive(), to avoid either side from
  301. unexpectedly closing the connection due to inactivity.
  302.  
  303. If an application does not need to integrate with an
  304. existing event loop implementation, then the
  305. virEventRegisterDefaultImpl() method can be used to setup
  306. the generic libvirt implementation. """
  307. libvirtmod.virEventRegisterImpl(addHandle, updateHandle, removeHandle, addTimeout, updateTimeout, removeTimeout)
  308.  
  309. def virEventRemoveHandle(watch):
  310. """Unregister a callback from a file handle. This function
  311. requires that an event loop has previously been registered with
  312. virEventRegisterImpl() or virEventRegisterDefaultImpl(). """
  313. ret = libvirtmod.virEventRemoveHandle(watch)
  314. if ret == -1: raise libvirtError ('virEventRemoveHandle() failed')
  315. return ret
  316.  
  317. def virEventRemoveTimeout(timer):
  318. """Unregister a callback for a timer. This function
  319. requires that an event loop has previously been registered with
  320. virEventRegisterImpl() or virEventRegisterDefaultImpl(). """
  321. ret = libvirtmod.virEventRemoveTimeout(timer)
  322. if ret == -1: raise libvirtError ('virEventRemoveTimeout() failed')
  323. return ret
  324.  
  325. def virEventRunDefaultImpl():
  326. """Run one iteration of the event loop. Applications
  327. will generally want to have a thread which invokes
  328. this method in an infinite loop. Furthermore, it is wise
  329. to set up a pipe-to-self handler (via virEventAddHandle())
  330. or a timeout (via virEventAddTimeout()) before calling this
  331. function, as it will block forever if there are no
  332. registered events.
  333.  
  334. static bool quit = false;
  335.  
  336. while (!quit) {
  337. if (virEventRunDefaultImpl() < 0)
  338. ...print error...
  339. } """
  340. ret = libvirtmod.virEventRunDefaultImpl()
  341. if ret == -1: raise libvirtError ('virEventRunDefaultImpl() failed')
  342. return ret
  343.  
  344. def virEventUpdateHandle(watch, events):
  345. """Change event set for a monitored file handle. This function
  346. requires that an event loop has previously been registered with
  347. virEventRegisterImpl() or virEventRegisterDefaultImpl().
  348.  
  349. Will not fail if fd exists. """
  350. libvirtmod.virEventUpdateHandle(watch, events)
  351.  
  352. def virEventUpdateTimeout(timer, timeout):
  353. """Change frequency for a timer. This function
  354. requires that an event loop has previously been registered with
  355. virEventRegisterImpl() or virEventRegisterDefaultImpl().
  356.  
  357. Setting frequency to -1 will disable the timer. Setting the frequency
  358. to zero will cause it to fire on every event loop iteration.
  359.  
  360. Will not fail if timer exists. """
  361. libvirtmod.virEventUpdateTimeout(timer, timeout)
  362.  
  363. #
  364. # Functions from module virterror
  365. #
  366.  
  367. def virGetLastError():
  368. """Provide a pointer to the last error caught at the library level
  369.  
  370. The error object is kept in thread local storage, so separate
  371. threads can safely access this concurrently. """
  372. ret = libvirtmod.virGetLastError()
  373. return ret
  374.  
  375. def virGetLastErrorMessage():
  376. """Get the most recent error message """
  377. ret = libvirtmod.virGetLastErrorMessage()
  378. if ret is None: raise libvirtError ('virGetLastErrorMessage() failed')
  379. return ret
  380.  
  381. #
  382. # Functions from module libvirt
  383. #
  384.  
  385. def virInitialize():
  386. """Initialize the library.
  387.  
  388. This method is invoked automatically by any of the virConnectOpen() API
  389. calls, and by virGetVersion(). Since release 1.0.0, there is no need to
  390. call this method even in a multithreaded application, since
  391. initialization is performed in a thread safe manner; but applications
  392. using an older version of the library should manually call this before
  393. setting up competing threads that attempt virConnectOpen in parallel.
  394.  
  395. The only other time it would be necessary to call virInitialize is if the
  396. application did not invoke virConnectOpen as its first API call, such
  397. as when calling virEventRegisterImpl() before setting up connections,
  398. or when using virSetErrorFunc() to alter error reporting of the first
  399. connection attempt. """
  400. ret = libvirtmod.virInitialize()
  401. if ret == -1: raise libvirtError ('virInitialize() failed')
  402. return ret
  403.  
  404. #
  405. # Functions from module virterror
  406. #
  407.  
  408. def virResetLastError():
  409. """Reset the last error caught at the library level.
  410.  
  411. The error object is kept in thread local storage, so separate
  412. threads can safely access this concurrently, only resetting
  413. their own error object. """
  414. libvirtmod.virResetLastError()
  415.  
  416. class virDomain(object):
  417. def __init__(self, conn, _obj=None):
  418. self._conn = conn
  419. self._o = _obj
  420.  
  421. def __del__(self):
  422. if self._o is not None:
  423. libvirtmod.virDomainFree(self._o)
  424. self._o = None
  425.  
  426. def connect(self):
  427. return self._conn
  428.  
  429. #
  430. # virDomain functions from module libvirt
  431. #
  432.  
  433. def ID(self):
  434. """Get the hypervisor ID number for the domain """
  435. ret = libvirtmod.virDomainGetID(self._o)
  436. return ret
  437.  
  438. def OSType(self):
  439. """Get the type of domain operation system. """
  440. ret = libvirtmod.virDomainGetOSType(self._o)
  441. if ret is None: raise libvirtError ('virDomainGetOSType() failed', dom=self)
  442. return ret
  443.  
  444. #
  445. # virDomain functions from module python
  446. #
  447.  
  448. def UUID(self):
  449. """Extract the UUID unique Identifier of a domain. """
  450. ret = libvirtmod.virDomainGetUUID(self._o)
  451. if ret is None: raise libvirtError ('virDomainGetUUID() failed', dom=self)
  452. return ret
  453.  
  454. def UUIDString(self):
  455. """Fetch globally unique ID of the domain as a string. """
  456. ret = libvirtmod.virDomainGetUUIDString(self._o)
  457. if ret is None: raise libvirtError ('virDomainGetUUIDString() failed', dom=self)
  458. return ret
  459.  
  460. #
  461. # virDomain functions from module libvirt
  462. #
  463.  
  464. def XMLDesc(self, flags=0):
  465. """Provide an XML description of the domain. The description may be reused
  466. later to relaunch the domain with virDomainCreateXML().
  467.  
  468. No security-sensitive data will be included unless @flags contains
  469. VIR_DOMAIN_XML_SECURE; this flag is rejected on read-only
  470. connections. If @flags includes VIR_DOMAIN_XML_INACTIVE, then the
  471. XML represents the configuration that will be used on the next boot
  472. of a persistent domain; otherwise, the configuration represents the
  473. currently running domain. If @flags contains
  474. VIR_DOMAIN_XML_UPDATE_CPU, then the portion of the domain XML
  475. describing CPU capabilities is modified to match actual
  476. capabilities of the host. """
  477. ret = libvirtmod.virDomainGetXMLDesc(self._o, flags)
  478. if ret is None: raise libvirtError ('virDomainGetXMLDesc() failed', dom=self)
  479. return ret
  480.  
  481. def abortJob(self):
  482. """Requests that the current background job be aborted at the
  483. soonest opportunity. """
  484. ret = libvirtmod.virDomainAbortJob(self._o)
  485. if ret == -1: raise libvirtError ('virDomainAbortJob() failed', dom=self)
  486. return ret
  487.  
  488. def attachDevice(self, xml):
  489. """Create a virtual device attachment to backend. This function,
  490. having hotplug semantics, is only allowed on an active domain.
  491.  
  492. For compatibility, this method can also be used to change the media
  493. in an existing CDROM/Floppy device, however, applications are
  494. recommended to use the virDomainUpdateDeviceFlag method instead.
  495.  
  496. Be aware that hotplug changes might not persist across a domain going
  497. into S4 state (also known as hibernation) unless you also modify the
  498. persistent domain definition. """
  499. ret = libvirtmod.virDomainAttachDevice(self._o, xml)
  500. if ret == -1: raise libvirtError ('virDomainAttachDevice() failed', dom=self)
  501. return ret
  502.  
  503. def attachDeviceFlags(self, xml, flags=0):
  504. """Attach a virtual device to a domain, using the flags parameter
  505. to control how the device is attached. VIR_DOMAIN_AFFECT_CURRENT
  506. specifies that the device allocation is made based on current domain
  507. state. VIR_DOMAIN_AFFECT_LIVE specifies that the device shall be
  508. allocated to the active domain instance only and is not added to the
  509. persisted domain configuration. VIR_DOMAIN_AFFECT_CONFIG
  510. specifies that the device shall be allocated to the persisted domain
  511. configuration only. Note that the target hypervisor must return an
  512. error if unable to satisfy flags. E.g. the hypervisor driver will
  513. return failure if LIVE is specified but it only supports modifying the
  514. persisted device allocation.
  515.  
  516. For compatibility, this method can also be used to change the media
  517. in an existing CDROM/Floppy device, however, applications are
  518. recommended to use the virDomainUpdateDeviceFlag method instead.
  519.  
  520. Be aware that hotplug changes might not persist across a domain going
  521. into S4 state (also known as hibernation) unless you also modify the
  522. persistent domain definition. """
  523. ret = libvirtmod.virDomainAttachDeviceFlags(self._o, xml, flags)
  524. if ret == -1: raise libvirtError ('virDomainAttachDeviceFlags() failed', dom=self)
  525. return ret
  526.  
  527. #
  528. # virDomain functions from module python
  529. #
  530.  
  531. def autostart(self):
  532. """Extract the autostart flag for a domain """
  533. ret = libvirtmod.virDomainGetAutostart(self._o)
  534. if ret == -1: raise libvirtError ('virDomainGetAutostart() failed', dom=self)
  535. return ret
  536.  
  537. def blkioParameters(self, flags=0):
  538. """Get the blkio parameters """
  539. ret = libvirtmod.virDomainGetBlkioParameters(self._o, flags)
  540. if ret is None: raise libvirtError ('virDomainGetBlkioParameters() failed', dom=self)
  541. return ret
  542.  
  543. #
  544. # virDomain functions from module libvirt
  545. #
  546.  
  547. def blockCommit(self, disk, base, top, bandwidth=0, flags=0):
  548. """Commit changes that were made to temporary top-level files within a disk
  549. image backing file chain into a lower-level base file. In other words,
  550. take all the difference between @base and @top, and update @base to contain
  551. that difference; after the commit, any portion of the chain that previously
  552. depended on @top will now depend on @base, and all files after @base up
  553. to and including @top will now be invalidated. A typical use of this
  554. command is to reduce the length of a backing file chain after taking an
  555. external disk snapshot. To move data in the opposite direction, see
  556. virDomainBlockPull().
  557.  
  558. This command starts a long-running commit block job, whose status may
  559. be tracked by virDomainBlockJobInfo() with a job type of
  560. VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT, and the operation can be aborted with
  561. virDomainBlockJobAbort(). When finished, an asynchronous event is
  562. raised to indicate the final status, and the job no longer exists. If
  563. the job is aborted, it is up to the hypervisor whether starting a new
  564. job will resume from the same point, or start over.
  565.  
  566. As a special case, if @top is the active image (or None), and @flags
  567. includes VIR_DOMAIN_BLOCK_COMMIT_ACTIVE, the block job will have a type
  568. of VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT, and operates in two phases.
  569. In the first phase, the contents are being committed into @base, and the
  570. job can only be canceled. The job transitions to the second phase when
  571. the job info states cur == end, and remains alive to keep all further
  572. changes to @top synchronized into @base; an event with status
  573. VIR_DOMAIN_BLOCK_JOB_READY is also issued to mark the job transition.
  574. Once in the second phase, the user must choose whether to cancel the job
  575. (keeping @top as the active image, but now containing only the changes
  576. since the time the job ended) or to pivot the job (adjusting to @base as
  577. the active image, and invalidating @top).
  578.  
  579. Be aware that this command may invalidate files even if it is aborted;
  580. the user is cautioned against relying on the contents of invalidated
  581. intermediate files such as @top (when @top is not the active image)
  582. without manually rebasing those files to use a backing file of a
  583. read-only copy of @base prior to the point where the commit operation
  584. was started (and such a rebase cannot be safely done until the commit
  585. has successfully completed). However, the domain itself will not have
  586. any issues; the active layer remains valid throughout the entire commit
  587. operation.
  588.  
  589. Some hypervisors may support a shortcut where if @flags contains
  590. VIR_DOMAIN_BLOCK_COMMIT_DELETE, then this command will unlink all files
  591. that were invalidated, after the commit successfully completes.
  592.  
  593. If @flags contains VIR_DOMAIN_BLOCK_COMMIT_RELATIVE, the name recorded
  594. into the overlay of the @top image (if there is such image) as the
  595. path to the new backing file will be kept relative to other images.
  596. The operation will fail if libvirt can't infer the name.
  597.  
  598. By default, if @base is None, the commit target will be the bottom of
  599. the backing chain; if @flags contains VIR_DOMAIN_BLOCK_COMMIT_SHALLOW,
  600. then the immediate backing file of @top will be used instead. If @top
  601. is None, the active image at the top of the chain will be used. Some
  602. hypervisors place restrictions on how much can be committed, and might
  603. fail if @base is not the immediate backing file of @top, or if @top is
  604. the active layer in use by a running domain but @flags did not include
  605. VIR_DOMAIN_BLOCK_COMMIT_ACTIVE, or if @top is not the top-most file;
  606. restrictions may differ for online vs. offline domains.
  607.  
  608. The @disk parameter is either an unambiguous source name of the
  609. block device (the <source file='...'/> sub-element, such as
  610. "/path/to/image"), or the device target shorthand (the
  611. <target dev='...'/> sub-element, such as "vda"). Valid names
  612. can be found by calling virDomainGetXMLDesc() and inspecting
  613. elements within //domain/devices/disk.
  614.  
  615. The @base and @top parameters can be either paths to files within the
  616. backing chain, or the device target shorthand (the <target dev='...'/>
  617. sub-element, such as "vda") followed by an index to the backing chain
  618. enclosed in square brackets. Backing chain indexes can be found by
  619. inspecting //disk//backingStore/@index in the domain XML. Thus, for
  620. example, "vda[3]" refers to the backing store with index equal to "3"
  621. in the chain of disk "vda".
  622.  
  623. The maximum bandwidth (in MiB/s) that will be used to do the commit can be
  624. specified with the bandwidth parameter. If set to 0, libvirt will choose a
  625. suitable default. Some hypervisors do not support this feature and will
  626. return an error if bandwidth is not 0; in this case, it might still be
  627. possible for a later call to virDomainBlockJobSetSpeed() to succeed.
  628. The actual speed can be determined with virDomainGetBlockJobInfo(). """
  629. ret = libvirtmod.virDomainBlockCommit(self._o, disk, base, top, bandwidth, flags)
  630. if ret == -1: raise libvirtError ('virDomainBlockCommit() failed', dom=self)
  631. return ret
  632.  
  633. #
  634. # virDomain functions from module python
  635. #
  636.  
  637. def blockCopy(self, disk, destxml, params=None, flags=0):
  638. """Copy the guest-visible contents of a disk image to a new file described by destxml """
  639. ret = libvirtmod.virDomainBlockCopy(self._o, disk, destxml, params, flags)
  640. if ret == -1: raise libvirtError ('virDomainBlockCopy() failed', dom=self)
  641. return ret
  642.  
  643. def blockInfo(self, path, flags=0):
  644. """Extract information about a domain block device size """
  645. ret = libvirtmod.virDomainGetBlockInfo(self._o, path, flags)
  646. if ret is None: raise libvirtError ('virDomainGetBlockInfo() failed', dom=self)
  647. return ret
  648.  
  649. def blockIoTune(self, disk, flags=0):
  650. """Get the I/O tunables for a block device """
  651. ret = libvirtmod.virDomainGetBlockIoTune(self._o, disk, flags)
  652. if ret is None: raise libvirtError ('virDomainGetBlockIoTune() failed', dom=self)
  653. return ret
  654.  
  655. #
  656. # virDomain functions from module libvirt
  657. #
  658.  
  659. def blockJobAbort(self, disk, flags=0):
  660. """Cancel the active block job on the given disk.
  661.  
  662. The @disk parameter is either an unambiguous source name of the
  663. block device (the <source file='...'/> sub-element, such as
  664. "/path/to/image"), or (since 0.9.5) the device target shorthand
  665. (the <target dev='...'/> sub-element, such as "vda"). Valid names
  666. can be found by calling virDomainGetXMLDesc() and inspecting
  667. elements within //domain/devices/disk.
  668.  
  669. If the current block job for @disk is VIR_DOMAIN_BLOCK_JOB_TYPE_PULL, then
  670. by default, this function performs a synchronous operation and the caller
  671. may assume that the operation has completed when 0 is returned. However,
  672. BlockJob operations may take a long time to cancel, and during this time
  673. further domain interactions may be unresponsive. To avoid this problem,
  674. pass VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC in the @flags argument to enable
  675. asynchronous behavior, returning as soon as possible. When the job has
  676. been canceled, a BlockJob event will be emitted, with status
  677. VIR_DOMAIN_BLOCK_JOB_CANCELED (even if the ABORT_ASYNC flag was not
  678. used); it is also possible to poll virDomainBlockJobInfo() to see if
  679. the job cancellation is still pending. This type of job can be restarted
  680. to pick up from where it left off.
  681.  
  682. If the current block job for @disk is VIR_DOMAIN_BLOCK_JOB_TYPE_COPY, then
  683. the default is to abort the mirroring and revert to the source disk;
  684. likewise, if the current job is VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT,
  685. the default is to abort without changing the active layer of @disk.
  686. Adding @flags of VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT causes this call to
  687. fail with VIR_ERR_BLOCK_COPY_ACTIVE if the copy or commit is not yet
  688. ready; otherwise it will swap the disk over to the new active image
  689. to end the mirroring or active commit. An event will be issued when the
  690. job is ended, and it is possible to use VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC
  691. to control whether this command waits for the completion of the job.
  692. Restarting a copy or active commit job requires starting over from the
  693. beginning of the first phase. """
  694. ret = libvirtmod.virDomainBlockJobAbort(self._o, disk, flags)
  695. if ret == -1: raise libvirtError ('virDomainBlockJobAbort() failed', dom=self)
  696. return ret
  697.  
  698. #
  699. # virDomain functions from module python
  700. #
  701.  
  702. def blockJobInfo(self, path, flags=0):
  703. """Get progress information for a block job """
  704. ret = libvirtmod.virDomainGetBlockJobInfo(self._o, path, flags)
  705. if ret is None: raise libvirtError ('virDomainGetBlockJobInfo() failed', dom=self)
  706. return ret
  707.  
  708. #
  709. # virDomain functions from module libvirt
  710. #
  711.  
  712. def blockJobSetSpeed(self, disk, bandwidth, flags=0):
  713. """Set the maximimum allowable bandwidth that a block job may consume. If
  714. bandwidth is 0, the limit will revert to the hypervisor default.
  715.  
  716. The @disk parameter is either an unambiguous source name of the
  717. block device (the <source file='...'/> sub-element, such as
  718. "/path/to/image"), or (since 0.9.5) the device target shorthand
  719. (the <target dev='...'/> sub-element, such as "vda"). Valid names
  720. can be found by calling virDomainGetXMLDesc() and inspecting
  721. elements within //domain/devices/disk. """
  722. ret = libvirtmod.virDomainBlockJobSetSpeed(self._o, disk, bandwidth, flags)
  723. if ret == -1: raise libvirtError ('virDomainBlockJobSetSpeed() failed', dom=self)
  724. return ret
  725.  
  726. #
  727. # virDomain functions from module python
  728. #
  729.  
  730. def blockPeek(self, disk, offset, size, flags=0):
  731. """Read the contents of domain's disk device """
  732. ret = libvirtmod.virDomainBlockPeek(self._o, disk, offset, size, flags)
  733. if ret is None: raise libvirtError ('virDomainBlockPeek() failed', dom=self)
  734. return ret
  735.  
  736. #
  737. # virDomain functions from module libvirt
  738. #
  739.  
  740. def blockPull(self, disk, bandwidth=0, flags=0):
  741. """Populate a disk image with data from its backing image. Once all data from
  742. its backing image has been pulled, the disk no longer depends on a backing
  743. image. This function pulls data for the entire device in the background.
  744. Progress of the operation can be checked with virDomainGetBlockJobInfo() and
  745. the operation can be aborted with virDomainBlockJobAbort(). When finished,
  746. an asynchronous event is raised to indicate the final status. To move
  747. data in the opposite direction, see virDomainBlockCommit().
  748.  
  749. The @disk parameter is either an unambiguous source name of the
  750. block device (the <source file='...'/> sub-element, such as
  751. "/path/to/image"), or (since 0.9.5) the device target shorthand
  752. (the <target dev='...'/> sub-element, such as "vda"). Valid names
  753. can be found by calling virDomainGetXMLDesc() and inspecting
  754. elements within //domain/devices/disk.
  755.  
  756. The maximum bandwidth (in MiB/s) that will be used to do the copy can be
  757. specified with the bandwidth parameter. If set to 0, libvirt will choose a
  758. suitable default. Some hypervisors do not support this feature and will
  759. return an error if bandwidth is not 0; in this case, it might still be
  760. possible for a later call to virDomainBlockJobSetSpeed() to succeed.
  761. The actual speed can be determined with virDomainGetBlockJobInfo().
  762.  
  763. This is shorthand for virDomainBlockRebase() with a None base. """
  764. ret = libvirtmod.virDomainBlockPull(self._o, disk, bandwidth, flags)
  765. if ret == -1: raise libvirtError ('virDomainBlockPull() failed', dom=self)
  766. return ret
  767.  
  768. def blockRebase(self, disk, base, bandwidth=0, flags=0):
  769. """Populate a disk image with data from its backing image chain, and
  770. setting the backing image to @base, or alternatively copy an entire
  771. backing chain to a new file @base.
  772.  
  773. When @flags is 0, this starts a pull, where @base must be the absolute
  774. path of one of the backing images further up the chain, or None to
  775. convert the disk image so that it has no backing image. Once all
  776. data from its backing image chain has been pulled, the disk no
  777. longer depends on those intermediate backing images. This function
  778. pulls data for the entire device in the background. Progress of
  779. the operation can be checked with virDomainGetBlockJobInfo() with a
  780. job type of VIR_DOMAIN_BLOCK_JOB_TYPE_PULL, and the operation can be
  781. aborted with virDomainBlockJobAbort(). When finished, an asynchronous
  782. event is raised to indicate the final status, and the job no longer
  783. exists. If the job is aborted, a new one can be started later to
  784. resume from the same point.
  785.  
  786. If @flags contains VIR_DOMAIN_BLOCK_REBASE_RELATIVE, the name recorded
  787. into the active disk as the location for @base will be kept relative.
  788. The operation will fail if libvirt can't infer the name.
  789.  
  790. When @flags includes VIR_DOMAIN_BLOCK_REBASE_COPY, this starts a copy,
  791. where @base must be the name of a new file to copy the chain to. By
  792. default, the copy will pull the entire source chain into the destination
  793. file, but if @flags also contains VIR_DOMAIN_BLOCK_REBASE_SHALLOW, then
  794. only the top of the source chain will be copied (the source and
  795. destination have a common backing file). By default, @base will be
  796. created with the same file format as the source, but this can be altered
  797. by adding VIR_DOMAIN_BLOCK_REBASE_COPY_RAW to force the copy to be raw
  798. (does not make sense with the shallow flag unless the source is also raw),
  799. or by using VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT to reuse an existing file
  800. which was pre-created with the correct format and metadata and sufficient
  801. size to hold the copy. In case the VIR_DOMAIN_BLOCK_REBASE_SHALLOW flag
  802. is used the pre-created file has to exhibit the same guest visible contents
  803. as the backing file of the original image. This allows a management app to
  804. pre-create files with relative backing file names, rather than the default
  805. of absolute backing file names; as a security precaution, you should
  806. generally only use reuse_ext with the shallow flag and a non-raw
  807. destination file. By default, the copy destination will be treated as
  808. type='file', but using VIR_DOMAIN_BLOCK_REBASE_COPY_DEV treats the
  809. destination as type='block' (affecting how virDomainGetBlockInfo() will
  810. report allocation after pivoting).
  811.  
  812. A copy job has two parts; in the first phase, the @bandwidth parameter
  813. affects how fast the source is pulled into the destination, and the job
  814. can only be canceled by reverting to the source file; progress in this
  815. phase can be tracked via the virDomainBlockJobInfo() command, with a
  816. job type of VIR_DOMAIN_BLOCK_JOB_TYPE_COPY. The job transitions to the
  817. second phase when the job info states cur == end, and remains alive to
  818. mirror all further changes to both source and destination. The user
  819. must call virDomainBlockJobAbort() to end the mirroring while choosing
  820. whether to revert to source or pivot to the destination. An event is
  821. issued when the job ends, and depending on the hypervisor, an event may
  822. also be issued when the job transitions from pulling to mirroring. If
  823. the job is aborted, a new job will have to start over from the beginning
  824. of the first phase.
  825.  
  826. Some hypervisors will restrict certain actions, such as virDomainSave()
  827. or virDomainDetachDevice(), while a copy job is active; they may
  828. also restrict a copy job to transient domains.
  829.  
  830. The @disk parameter is either an unambiguous source name of the
  831. block device (the <source file='...'/> sub-element, such as
  832. "/path/to/image"), or the device target shorthand (the
  833. <target dev='...'/> sub-element, such as "vda"). Valid names
  834. can be found by calling virDomainGetXMLDesc() and inspecting
  835. elements within //domain/devices/disk.
  836.  
  837. The @base parameter can be either a path to a file within the backing
  838. chain, or the device target shorthand (the <target dev='...'/>
  839. sub-element, such as "vda") followed by an index to the backing chain
  840. enclosed in square brackets. Backing chain indexes can be found by
  841. inspecting //disk//backingStore/@index in the domain XML. Thus, for
  842. example, "vda[3]" refers to the backing store with index equal to "3"
  843. in the chain of disk "vda".
  844.  
  845. The maximum bandwidth (in MiB/s) that will be used to do the copy can be
  846. specified with the bandwidth parameter. If set to 0, libvirt will choose a
  847. suitable default. Some hypervisors do not support this feature and will
  848. return an error if bandwidth is not 0; in this case, it might still be
  849. possible for a later call to virDomainBlockJobSetSpeed() to succeed.
  850. The actual speed can be determined with virDomainGetBlockJobInfo().
  851.  
  852. When @base is None and @flags is 0, this is identical to
  853. virDomainBlockPull(). When @flags contains VIR_DOMAIN_BLOCK_REBASE_COPY,
  854. this command is shorthand for virDomainBlockCopy() where the destination
  855. XML encodes @base as a <disk type='file'>, @bandwidth is properly scaled
  856. and passed as a typed parameter, the shallow and reuse external flags
  857. are preserved, and remaining flags control whether the XML encodes a
  858. destination format of raw instead of leaving the destination identical
  859. to the source format or probed from the reused file. """
  860. ret = libvirtmod.virDomainBlockRebase(self._o, disk, base, bandwidth, flags)
  861. if ret == -1: raise libvirtError ('virDomainBlockRebase() failed', dom=self)
  862. return ret
  863.  
  864. def blockResize(self, disk, size, flags=0):
  865. """Resize a block device of domain while the domain is running. If
  866. @flags is 0, then @size is in kibibytes (blocks of 1024 bytes);
  867. since 0.9.11, if @flags includes VIR_DOMAIN_BLOCK_RESIZE_BYTES,
  868. @size is in bytes instead. @size is taken directly as the new
  869. size. Depending on the file format, the hypervisor may round up
  870. to the next alignment boundary.
  871.  
  872. The @disk parameter is either an unambiguous source name of the
  873. block device (the <source file='...'/> sub-element, such as
  874. "/path/to/image"), or (since 0.9.5) the device target shorthand
  875. (the <target dev='...'/> sub-element, such as "vda"). Valid names
  876. can be found by calling virDomainGetXMLDesc() and inspecting
  877. elements within //domain/devices/disk.
  878.  
  879. Note that this call may fail if the underlying virtualization hypervisor
  880. does not support it; this call requires privileged access to the
  881. hypervisor. """
  882. ret = libvirtmod.virDomainBlockResize(self._o, disk, size, flags)
  883. if ret == -1: raise libvirtError ('virDomainBlockResize() failed', dom=self)
  884. return ret
  885.  
  886. #
  887. # virDomain functions from module python
  888. #
  889.  
  890. def blockStats(self, path):
  891. """Extracts block device statistics for a domain """
  892. ret = libvirtmod.virDomainBlockStats(self._o, path)
  893. if ret is None: raise libvirtError ('virDomainBlockStats() failed', dom=self)
  894. return ret
  895.  
  896. def blockStatsFlags(self, path, flags=0):
  897. """Extracts block device statistics parameters of a running domain """
  898. ret = libvirtmod.virDomainBlockStatsFlags(self._o, path, flags)
  899. if ret is None: raise libvirtError ('virDomainBlockStatsFlags() failed', dom=self)
  900. return ret
  901.  
  902. def controlInfo(self, flags=0):
  903. """Extract details about current state of control interface to a domain. """
  904. ret = libvirtmod.virDomainGetControlInfo(self._o, flags)
  905. if ret is None: raise libvirtError ('virDomainGetControlInfo() failed', dom=self)
  906. return ret
  907.  
  908. #
  909. # virDomain functions from module libvirt
  910. #
  911.  
  912. def coreDump(self, to, flags=0):
  913. """This method will dump the core of a domain on a given file for analysis.
  914. Note that for remote Xen Daemon the file path will be interpreted in
  915. the remote host. Hypervisors may require the user to manually ensure
  916. proper permissions on the file named by @to.
  917.  
  918. If @flags includes VIR_DUMP_CRASH, then leave the guest shut off with
  919. a crashed state after the dump completes. If @flags includes
  920. VIR_DUMP_LIVE, then make the core dump while continuing to allow
  921. the guest to run; otherwise, the guest is suspended during the dump.
  922. VIR_DUMP_RESET flag forces reset of the guest after dump.
  923. The above three flags are mutually exclusive.
  924.  
  925. Additionally, if @flags includes VIR_DUMP_BYPASS_CACHE, then libvirt
  926. will attempt to bypass the file system cache while creating the file,
  927. or fail if it cannot do so for the given system; this can allow less
  928. pressure on file system cache, but also risks slowing saves to NFS.
  929.  
  930. For more control over the output format, see virDomainCoreDumpWithFormat(). """
  931. ret = libvirtmod.virDomainCoreDump(self._o, to, flags)
  932. if ret == -1: raise libvirtError ('virDomainCoreDump() failed', dom=self)
  933. return ret
  934.  
  935. def coreDumpWithFormat(self, to, dumpformat, flags=0):
  936. """This method will dump the core of a domain on a given file for analysis.
  937. Note that for remote Xen Daemon the file path will be interpreted in
  938. the remote host. Hypervisors may require the user to manually ensure
  939. proper permissions on the file named by @to.
  940.  
  941. @dumpformat controls which format the dump will have; use of
  942. VIR_DOMAIN_CORE_DUMP_FORMAT_RAW mirrors what virDomainCoreDump() will
  943. perform. Not all hypervisors are able to support all formats.
  944.  
  945. If @flags includes VIR_DUMP_CRASH, then leave the guest shut off with
  946. a crashed state after the dump completes. If @flags includes
  947. VIR_DUMP_LIVE, then make the core dump while continuing to allow
  948. the guest to run; otherwise, the guest is suspended during the dump.
  949. VIR_DUMP_RESET flag forces reset of the guest after dump.
  950. The above three flags are mutually exclusive.
  951.  
  952. Additionally, if @flags includes VIR_DUMP_BYPASS_CACHE, then libvirt
  953. will attempt to bypass the file system cache while creating the file,
  954. or fail if it cannot do so for the given system; this can allow less
  955. pressure on file system cache, but also risks slowing saves to NFS. """
  956. ret = libvirtmod.virDomainCoreDumpWithFormat(self._o, to, dumpformat, flags)
  957. if ret == -1: raise libvirtError ('virDomainCoreDumpWithFormat() failed', dom=self)
  958. return ret
  959.  
  960. def create(self):
  961. """Launch a defined domain. If the call succeeds the domain moves from the
  962. defined to the running domains pools. The domain will be paused only
  963. if restoring from managed state created from a paused domain. For more
  964. control, see virDomainCreateWithFlags(). """
  965. ret = libvirtmod.virDomainCreate(self._o)
  966. if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
  967. return ret
  968.  
  969. def createWithFlags(self, flags=0):
  970. """Launch a defined domain. If the call succeeds the domain moves from the
  971. defined to the running domains pools.
  972.  
  973. If the VIR_DOMAIN_START_PAUSED flag is set, or if the guest domain
  974. has a managed save image that requested paused state (see
  975. virDomainManagedSave()) the guest domain will be started, but its
  976. CPUs will remain paused. The CPUs can later be manually started
  977. using virDomainResume(). In all other cases, the guest domain will
  978. be running.
  979.  
  980. If the VIR_DOMAIN_START_AUTODESTROY flag is set, the guest
  981. domain will be automatically destroyed when the virConnectPtr
  982. object is finally released. This will also happen if the
  983. client application crashes / loses its connection to the
  984. libvirtd daemon. Any domains marked for auto destroy will
  985. block attempts at migration, save-to-file, or snapshots.
  986.  
  987. If the VIR_DOMAIN_START_BYPASS_CACHE flag is set, and there is a
  988. managed save file for this domain (created by virDomainManagedSave()),
  989. then libvirt will attempt to bypass the file system cache while restoring
  990. the file, or fail if it cannot do so for the given system; this can allow
  991. less pressure on file system cache, but also risks slowing loads from NFS.
  992.  
  993. If the VIR_DOMAIN_START_FORCE_BOOT flag is set, then any managed save
  994. file for this domain is discarded, and the domain boots from scratch. """
  995. ret = libvirtmod.virDomainCreateWithFlags(self._o, flags)
  996. if ret == -1: raise libvirtError ('virDomainCreateWithFlags() failed', dom=self)
  997. return ret
  998.  
  999. def destroy(self):
  1000. """Destroy the domain object. The running instance is shutdown if not down
  1001. already and all resources used by it are given back to the hypervisor. This
  1002. does not free the associated virDomainPtr object.
  1003. This function may require privileged access.
  1004.  
  1005. virDomainDestroy first requests that a guest terminate
  1006. (e.g. SIGTERM), then waits for it to comply. After a reasonable
  1007. timeout, if the guest still exists, virDomainDestroy will
  1008. forcefully terminate the guest (e.g. SIGKILL) if necessary (which
  1009. may produce undesirable results, for example unflushed disk cache
  1010. in the guest). To avoid this possibility, it's recommended to
  1011. instead call virDomainDestroyFlags, sending the
  1012. VIR_DOMAIN_DESTROY_GRACEFUL flag.
  1013.  
  1014. If the domain is transient and has any snapshot metadata (see
  1015. virDomainSnapshotNum()), then that metadata will automatically
  1016. be deleted when the domain quits. """
  1017. ret = libvirtmod.virDomainDestroy(self._o)
  1018. if ret == -1: raise libvirtError ('virDomainDestroy() failed', dom=self)
  1019. return ret
  1020.  
  1021. def destroyFlags(self, flags=0):
  1022. """Destroy the domain object. The running instance is shutdown if not down
  1023. already and all resources used by it are given back to the hypervisor.
  1024. This does not free the associated virDomainPtr object.
  1025. This function may require privileged access.
  1026.  
  1027. Calling this function with no @flags set (equal to zero) is
  1028. equivalent to calling virDomainDestroy, and after a reasonable
  1029. timeout will forcefully terminate the guest (e.g. SIGKILL) if
  1030. necessary (which may produce undesirable results, for example
  1031. unflushed disk cache in the guest). Including
  1032. VIR_DOMAIN_DESTROY_GRACEFUL in the flags will prevent the forceful
  1033. termination of the guest, and virDomainDestroyFlags will instead
  1034. return an error if the guest doesn't terminate by the end of the
  1035. timeout; at that time, the management application can decide if
  1036. calling again without VIR_DOMAIN_DESTROY_GRACEFUL is appropriate.
  1037.  
  1038. Another alternative which may produce cleaner results for the
  1039. guest's disks is to use virDomainShutdown() instead, but that
  1040. depends on guest support (some hypervisor/guest combinations may
  1041. ignore the shutdown request). """
  1042. ret = libvirtmod.virDomainDestroyFlags(self._o, flags)
  1043. if ret == -1: raise libvirtError ('virDomainDestroyFlags() failed', dom=self)
  1044. return ret
  1045.  
  1046. def detachDevice(self, xml):
  1047. """Destroy a virtual device attachment to backend. This function,
  1048. having hot-unplug semantics, is only allowed on an active domain.
  1049.  
  1050. Be aware that hotplug changes might not persist across a domain going
  1051. into S4 state (also known as hibernation) unless you also modify the
  1052. persistent domain definition. """
  1053. ret = libvirtmod.virDomainDetachDevice(self._o, xml)
  1054. if ret == -1: raise libvirtError ('virDomainDetachDevice() failed', dom=self)
  1055. return ret
  1056.  
  1057. def detachDeviceFlags(self, xml, flags=0):
  1058. """Detach a virtual device from a domain, using the flags parameter
  1059. to control how the device is detached. VIR_DOMAIN_AFFECT_CURRENT
  1060. specifies that the device allocation is removed based on current domain
  1061. state. VIR_DOMAIN_AFFECT_LIVE specifies that the device shall be
  1062. deallocated from the active domain instance only and is not from the
  1063. persisted domain configuration. VIR_DOMAIN_AFFECT_CONFIG
  1064. specifies that the device shall be deallocated from the persisted domain
  1065. configuration only. Note that the target hypervisor must return an
  1066. error if unable to satisfy flags. E.g. the hypervisor driver will
  1067. return failure if LIVE is specified but it only supports removing the
  1068. persisted device allocation.
  1069.  
  1070. Some hypervisors may prevent this operation if there is a current
  1071. block copy operation on the device being detached; in that case,
  1072. use virDomainBlockJobAbort() to stop the block copy first.
  1073.  
  1074. Beware that depending on the hypervisor and device type, detaching a device
  1075. from a running domain may be asynchronous. That is, calling
  1076. virDomainDetachDeviceFlags may just request device removal while the device
  1077. is actually removed later (in cooperation with a guest OS). Previously,
  1078. this fact was ignored and the device could have been removed from domain
  1079. configuration before it was actually removed by the hypervisor causing
  1080. various failures on subsequent operations. To check whether the device was
  1081. successfully removed, either recheck domain configuration using
  1082. virDomainGetXMLDesc() or add handler for VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED
  1083. event. In case the device is already gone when virDomainDetachDeviceFlags
  1084. returns, the event is delivered before this API call ends. To help existing
  1085. clients work better in most cases, this API will try to transform an
  1086. asynchronous device removal that finishes shortly after the request into
  1087. a synchronous removal. In other words, this API may wait a bit for the
  1088. removal to complete in case it was not synchronous.
  1089.  
  1090. Be aware that hotplug changes might not persist across a domain going
  1091. into S4 state (also known as hibernation) unless you also modify the
  1092. persistent domain definition. """
  1093. ret = libvirtmod.virDomainDetachDeviceFlags(self._o, xml, flags)
  1094. if ret == -1: raise libvirtError ('virDomainDetachDeviceFlags() failed', dom=self)
  1095. return ret
  1096.  
  1097. #
  1098. # virDomain functions from module python
  1099. #
  1100.  
  1101. def diskErrors(self, flags=0):
  1102. """Extract errors on disk devices. """
  1103. ret = libvirtmod.virDomainGetDiskErrors(self._o, flags)
  1104. if ret is None: raise libvirtError ('virDomainGetDiskErrors() failed', dom=self)
  1105. return ret
  1106.  
  1107. def emulatorPinInfo(self, flags=0):
  1108. """Query the CPU affinity setting of the emulator process of domain """
  1109. ret = libvirtmod.virDomainGetEmulatorPinInfo(self._o, flags)
  1110. if ret is None: raise libvirtError ('virDomainGetEmulatorPinInfo() failed', dom=self)
  1111. return ret
  1112.  
  1113. #
  1114. # virDomain functions from module libvirt
  1115. #
  1116.  
  1117. def fSTrim(self, mountPoint, minimum, flags=0):
  1118. """Calls FITRIM within the guest (hence guest agent may be
  1119. required depending on hypervisor used). Either call it on each
  1120. mounted filesystem (@mountPoint is None) or just on specified
  1121. @mountPoint. @minimum hints that free ranges smaller than this
  1122. may be ignored (this is a hint and the guest may not respect
  1123. it). By increasing this value, the fstrim operation will
  1124. complete more quickly for filesystems with badly fragmented
  1125. free space, although not all blocks will be discarded.
  1126. If @minimum is not zero, the command may fail. """
  1127. ret = libvirtmod.virDomainFSTrim(self._o, mountPoint, minimum, flags)
  1128. if ret == -1: raise libvirtError ('virDomainFSTrim() failed', dom=self)
  1129. return ret
  1130.  
  1131. #
  1132. # virDomain functions from module python
  1133. #
  1134.  
  1135. def getCPUStats(self, total, flags=0):
  1136. """Extracts CPU statistics for a running domain. On success it will
  1137. return a list of data of dictionary type. If boolean total is False or 0, the
  1138. first element of the list refers to CPU0 on the host, second element is
  1139. CPU1, and so on. The format of data struct is as follows:
  1140. [{cpu_time:xxx}, {cpu_time:xxx}, ...]
  1141. If it is True or 1, it returns total domain CPU statistics in the format of
  1142. [{cpu_time:xxx, user_time:xxx, system_time:xxx}] """
  1143. ret = libvirtmod.virDomainGetCPUStats(self._o, total, flags)
  1144. if ret is None: raise libvirtError ('virDomainGetCPUStats() failed', dom=self)
  1145. return ret
  1146.  
  1147. #
  1148. # virDomain functions from module libvirt
  1149. #
  1150.  
  1151. def hasCurrentSnapshot(self, flags=0):
  1152. """Determine if the domain has a current snapshot. """
  1153. ret = libvirtmod.virDomainHasCurrentSnapshot(self._o, flags)
  1154. if ret == -1: raise libvirtError ('virDomainHasCurrentSnapshot() failed', dom=self)
  1155. return ret
  1156.  
  1157. def hasManagedSaveImage(self, flags=0):
  1158. """Check if a domain has a managed save image as created by
  1159. virDomainManagedSave(). Note that any running domain should not have
  1160. such an image, as it should have been removed on restart. """
  1161. ret = libvirtmod.virDomainHasManagedSaveImage(self._o, flags)
  1162. if ret == -1: raise libvirtError ('virDomainHasManagedSaveImage() failed', dom=self)
  1163. return ret
  1164.  
  1165. def hostname(self, flags=0):
  1166. """Get the hostname for that domain.
  1167.  
  1168. Dependent on hypervisor used, this may require a guest agent to be
  1169. available. """
  1170. ret = libvirtmod.virDomainGetHostname(self._o, flags)
  1171. if ret is None: raise libvirtError ('virDomainGetHostname() failed', dom=self)
  1172. return ret
  1173.  
  1174. #
  1175. # virDomain functions from module python
  1176. #
  1177.  
  1178. def info(self):
  1179. """Extract information about a domain. Note that if the connection used to get the domain is limited only a partial set of the information can be extracted. """
  1180. ret = libvirtmod.virDomainGetInfo(self._o)
  1181. if ret is None: raise libvirtError ('virDomainGetInfo() failed', dom=self)
  1182. return ret
  1183.  
  1184. #
  1185. # virDomain functions from module libvirt
  1186. #
  1187.  
  1188. def injectNMI(self, flags=0):
  1189. """Send NMI to the guest """
  1190. ret = libvirtmod.virDomainInjectNMI(self._o, flags)
  1191. if ret == -1: raise libvirtError ('virDomainInjectNMI() failed', dom=self)
  1192. return ret
  1193.  
  1194. #
  1195. # virDomain functions from module python
  1196. #
  1197.  
  1198. def interfaceParameters(self, device, flags=0):
  1199. """Get the bandwidth tunables for a interface device """
  1200. ret = libvirtmod.virDomainGetInterfaceParameters(self._o, device, flags)
  1201. if ret is None: raise libvirtError ('virDomainGetInterfaceParameters() failed', dom=self)
  1202. return ret
  1203.  
  1204. def interfaceStats(self, path):
  1205. """Extracts interface device statistics for a domain """
  1206. ret = libvirtmod.virDomainInterfaceStats(self._o, path)
  1207. if ret is None: raise libvirtError ('virDomainInterfaceStats() failed', dom=self)
  1208. return ret
  1209.  
  1210. #
  1211. # virDomain functions from module libvirt
  1212. #
  1213.  
  1214. def isActive(self):
  1215. """Determine if the domain is currently running """
  1216. ret = libvirtmod.virDomainIsActive(self._o)
  1217. if ret == -1: raise libvirtError ('virDomainIsActive() failed', dom=self)
  1218. return ret
  1219.  
  1220. def isPersistent(self):
  1221. """Determine if the domain has a persistent configuration
  1222. which means it will still exist after shutting down """
  1223. ret = libvirtmod.virDomainIsPersistent(self._o)
  1224. if ret == -1: raise libvirtError ('virDomainIsPersistent() failed', dom=self)
  1225. return ret
  1226.  
  1227. def isUpdated(self):
  1228. """Determine if the domain has been updated. """
  1229. ret = libvirtmod.virDomainIsUpdated(self._o)
  1230. if ret == -1: raise libvirtError ('virDomainIsUpdated() failed', dom=self)
  1231. return ret
  1232.  
  1233. #
  1234. # virDomain functions from module python
  1235. #
  1236.  
  1237. def jobInfo(self):
  1238. """Extract information about an active job being processed for a domain. """
  1239. ret = libvirtmod.virDomainGetJobInfo(self._o)
  1240. if ret is None: raise libvirtError ('virDomainGetJobInfo() failed', dom=self)
  1241. return ret
  1242.  
  1243. def jobStats(self, flags=0):
  1244. """Extract information about an active job being processed for a domain. """
  1245. ret = libvirtmod.virDomainGetJobStats(self._o, flags)
  1246. if ret is None: raise libvirtError ('virDomainGetJobStats() failed', dom=self)
  1247. return ret
  1248.  
  1249. #
  1250. # virDomain functions from module libvirt
  1251. #
  1252.  
  1253. def managedSave(self, flags=0):
  1254. """This method will suspend a domain and save its memory contents to
  1255. a file on disk. After the call, if successful, the domain is not
  1256. listed as running anymore.
  1257. The difference from virDomainSave() is that libvirt is keeping track of
  1258. the saved state itself, and will reuse it once the domain is being
  1259. restarted (automatically or via an explicit libvirt call).
  1260. As a result any running domain is sure to not have a managed saved image.
  1261. This also implies that managed save only works on persistent domains,
  1262. since the domain must still exist in order to use virDomainCreate() to
  1263. restart it.
  1264.  
  1265. If @flags includes VIR_DOMAIN_SAVE_BYPASS_CACHE, then libvirt will
  1266. attempt to bypass the file system cache while creating the file, or
  1267. fail if it cannot do so for the given system; this can allow less
  1268. pressure on file system cache, but also risks slowing saves to NFS.
  1269.  
  1270. Normally, the managed saved state will remember whether the domain
  1271. was running or paused, and start will resume to the same state.
  1272. Specifying VIR_DOMAIN_SAVE_RUNNING or VIR_DOMAIN_SAVE_PAUSED in
  1273. @flags will override the default saved into the file. These two
  1274. flags are mutually exclusive. """
  1275. ret = libvirtmod.virDomainManagedSave(self._o, flags)
  1276. if ret == -1: raise libvirtError ('virDomainManagedSave() failed', dom=self)
  1277. return ret
  1278.  
  1279. def managedSaveRemove(self, flags=0):
  1280. """Remove any managed save image for this domain. """
  1281. ret = libvirtmod.virDomainManagedSaveRemove(self._o, flags)
  1282. if ret == -1: raise libvirtError ('virDomainManagedSaveRemove() failed', dom=self)
  1283. return ret
  1284.  
  1285. def maxMemory(self):
  1286. """Retrieve the maximum amount of physical memory allocated to a
  1287. domain. If domain is None, then this get the amount of memory reserved
  1288. to Domain0 i.e. the domain where the application runs. """
  1289. ret = libvirtmod.virDomainGetMaxMemory(self._o)
  1290. if ret == 0: raise libvirtError ('virDomainGetMaxMemory() failed', dom=self)
  1291. return ret
  1292.  
  1293. def maxVcpus(self):
  1294. """Provides the maximum number of virtual CPUs supported for
  1295. the guest VM. If the guest is inactive, this is basically
  1296. the same as virConnectGetMaxVcpus(). If the guest is running
  1297. this will reflect the maximum number of virtual CPUs the
  1298. guest was booted with. For more details, see virDomainGetVcpusFlags(). """
  1299. ret = libvirtmod.virDomainGetMaxVcpus(self._o)
  1300. if ret == -1: raise libvirtError ('virDomainGetMaxVcpus() failed', dom=self)
  1301. return ret
  1302.  
  1303. #
  1304. # virDomain functions from module python
  1305. #
  1306.  
  1307. def memoryParameters(self, flags=0):
  1308. """Get the memory parameters """
  1309. ret = libvirtmod.virDomainGetMemoryParameters(self._o, flags)
  1310. if ret is None: raise libvirtError ('virDomainGetMemoryParameters() failed', dom=self)
  1311. return ret
  1312.  
  1313. def memoryPeek(self, start, size, flags=0):
  1314. """Read the contents of domain's memory """
  1315. ret = libvirtmod.virDomainMemoryPeek(self._o, start, size, flags)
  1316. if ret is None: raise libvirtError ('virDomainMemoryPeek() failed', dom=self)
  1317. return ret
  1318.  
  1319. def memoryStats(self):
  1320. """Extracts memory statistics for a domain """
  1321. ret = libvirtmod.virDomainMemoryStats(self._o)
  1322. if ret is None: raise libvirtError ('virDomainMemoryStats() failed', dom=self)
  1323. return ret
  1324.  
  1325. #
  1326. # virDomain functions from module libvirt
  1327. #
  1328.  
  1329. def metadata(self, type, uri, flags=0):
  1330. """Retrieves the appropriate domain element given by @type.
  1331. If VIR_DOMAIN_METADATA_ELEMENT is requested parameter @uri
  1332. must be set to the name of the namespace the requested elements
  1333. belong to, otherwise must be None.
  1334.  
  1335. If an element of the domain XML is not present, the resulting
  1336. error will be VIR_ERR_NO_DOMAIN_METADATA. This method forms
  1337. a shortcut for seeing information from virDomainSetMetadata()
  1338. without having to go through virDomainGetXMLDesc().
  1339.  
  1340. @flags controls whether the live domain or persistent
  1341. configuration will be queried. """
  1342. ret = libvirtmod.virDomainGetMetadata(self._o, type, uri, flags)
  1343. if ret is None: raise libvirtError ('virDomainGetMetadata() failed', dom=self)
  1344. return ret
  1345.  
  1346. def migrate(self, dconn, flags=0, dname=None, uri=None, bandwidth=0):
  1347. """Migrate the domain object from its current host to the destination
  1348. host given by dconn (a connection to the destination host).
  1349.  
  1350. Flags may be one of more of the following:
  1351. VIR_MIGRATE_LIVE Do not pause the VM during migration
  1352. VIR_MIGRATE_PEER2PEER Direct connection between source & destination hosts
  1353. VIR_MIGRATE_TUNNELLED Tunnel migration data over the libvirt RPC channel
  1354. VIR_MIGRATE_PERSIST_DEST If the migration is successful, persist the domain
  1355. on the destination host.
  1356. VIR_MIGRATE_UNDEFINE_SOURCE If the migration is successful, undefine the
  1357. domain on the source host.
  1358. VIR_MIGRATE_PAUSED Leave the domain suspended on the remote side.
  1359. VIR_MIGRATE_NON_SHARED_DISK Migration with non-shared storage with full
  1360. disk copy
  1361. VIR_MIGRATE_NON_SHARED_INC Migration with non-shared storage with
  1362. incremental disk copy
  1363. VIR_MIGRATE_CHANGE_PROTECTION Protect against domain configuration
  1364. changes during the migration process (set
  1365. automatically when supported).
  1366. VIR_MIGRATE_UNSAFE Force migration even if it is considered unsafe.
  1367. VIR_MIGRATE_OFFLINE Migrate offline
  1368.  
  1369. VIR_MIGRATE_TUNNELLED requires that VIR_MIGRATE_PEER2PEER be set.
  1370. Applications using the VIR_MIGRATE_PEER2PEER flag will probably
  1371. prefer to invoke virDomainMigrateToURI, avoiding the need to
  1372. open connection to the destination host themselves.
  1373.  
  1374. If a hypervisor supports renaming domains during migration,
  1375. then you may set the dname parameter to the new name (otherwise
  1376. it keeps the same name). If this is not supported by the
  1377. hypervisor, dname must be None or else you will get an error.
  1378.  
  1379. If the VIR_MIGRATE_PEER2PEER flag is set, the uri parameter
  1380. must be a valid libvirt connection URI, by which the source
  1381. libvirt driver can connect to the destination libvirt. If
  1382. omitted, the dconn connection object will be queried for its
  1383. current URI.
  1384.  
  1385. If the VIR_MIGRATE_PEER2PEER flag is NOT set, the URI parameter
  1386. takes a hypervisor specific format. The hypervisor capabilities
  1387. XML includes details of the support URI schemes. If omitted
  1388. the dconn will be asked for a default URI.
  1389.  
  1390. If you want to copy non-shared storage within migration you
  1391. can use either VIR_MIGRATE_NON_SHARED_DISK or
  1392. VIR_MIGRATE_NON_SHARED_INC as they are mutually exclusive.
  1393.  
  1394. In either case it is typically only necessary to specify a
  1395. URI if the destination host has multiple interfaces and a
  1396. specific interface is required to transmit migration data.
  1397.  
  1398. The maximum bandwidth (in MiB/s) that will be used to do migration
  1399. can be specified with the bandwidth parameter. If set to 0,
  1400. libvirt will choose a suitable default. Some hypervisors do
  1401. not support this feature and will return an error if bandwidth
  1402. is not 0.
  1403.  
  1404. To see which features are supported by the current hypervisor,
  1405. see virConnectGetCapabilities, /capabilities/host/migration_features.
  1406.  
  1407. There are many limitations on migration imposed by the underlying
  1408. technology - for example it may not be possible to migrate between
  1409. different processors even with the same architecture, or between
  1410. different types of hypervisor.
  1411.  
  1412. virDomainFree should be used to free the resources after the
  1413. returned domain object is no longer needed. """
  1414. if dconn is None: dconn__o = None
  1415. else: dconn__o = dconn._o
  1416. ret = libvirtmod.virDomainMigrate(self._o, dconn__o, flags, dname, uri, bandwidth)
  1417. if ret is None:raise libvirtError('virDomainMigrate() failed', dom=self)
  1418. __tmp = virDomain(self,_obj=ret)
  1419. return __tmp
  1420.  
  1421. def migrate2(self, dconn, dxml=None, flags=0, dname=None, uri=None, bandwidth=0):
  1422. """Migrate the domain object from its current host to the destination
  1423. host given by dconn (a connection to the destination host).
  1424.  
  1425. Flags may be one of more of the following:
  1426. VIR_MIGRATE_LIVE Do not pause the VM during migration
  1427. VIR_MIGRATE_PEER2PEER Direct connection between source & destination hosts
  1428. VIR_MIGRATE_TUNNELLED Tunnel migration data over the libvirt RPC channel
  1429. VIR_MIGRATE_PERSIST_DEST If the migration is successful, persist the domain
  1430. on the destination host.
  1431. VIR_MIGRATE_UNDEFINE_SOURCE If the migration is successful, undefine the
  1432. domain on the source host.
  1433. VIR_MIGRATE_PAUSED Leave the domain suspended on the remote side.
  1434. VIR_MIGRATE_NON_SHARED_DISK Migration with non-shared storage with full
  1435. disk copy
  1436. VIR_MIGRATE_NON_SHARED_INC Migration with non-shared storage with
  1437. incremental disk copy
  1438. VIR_MIGRATE_CHANGE_PROTECTION Protect against domain configuration
  1439. changes during the migration process (set
  1440. automatically when supported).
  1441. VIR_MIGRATE_UNSAFE Force migration even if it is considered unsafe.
  1442. VIR_MIGRATE_OFFLINE Migrate offline
  1443.  
  1444. VIR_MIGRATE_TUNNELLED requires that VIR_MIGRATE_PEER2PEER be set.
  1445. Applications using the VIR_MIGRATE_PEER2PEER flag will probably
  1446. prefer to invoke virDomainMigrateToURI, avoiding the need to
  1447. open connection to the destination host themselves.
  1448.  
  1449. If a hypervisor supports renaming domains during migration,
  1450. then you may set the dname parameter to the new name (otherwise
  1451. it keeps the same name). If this is not supported by the
  1452. hypervisor, dname must be None or else you will get an error.
  1453.  
  1454. If the VIR_MIGRATE_PEER2PEER flag is set, the uri parameter
  1455. must be a valid libvirt connection URI, by which the source
  1456. libvirt driver can connect to the destination libvirt. If
  1457. omitted, the dconn connection object will be queried for its
  1458. current URI.
  1459.  
  1460. If the VIR_MIGRATE_PEER2PEER flag is NOT set, the URI parameter
  1461. takes a hypervisor specific format. The hypervisor capabilities
  1462. XML includes details of the support URI schemes. If omitted
  1463. the dconn will be asked for a default URI.
  1464.  
  1465. If you want to copy non-shared storage within migration you
  1466. can use either VIR_MIGRATE_NON_SHARED_DISK or
  1467. VIR_MIGRATE_NON_SHARED_INC as they are mutually exclusive.
  1468.  
  1469. In either case it is typically only necessary to specify a
  1470. URI if the destination host has multiple interfaces and a
  1471. specific interface is required to transmit migration data.
  1472.  
  1473. The maximum bandwidth (in MiB/s) that will be used to do migration
  1474. can be specified with the bandwidth parameter. If set to 0,
  1475. libvirt will choose a suitable default. Some hypervisors do
  1476. not support this feature and will return an error if bandwidth
  1477. is not 0.
  1478.  
  1479. To see which features are supported by the current hypervisor,
  1480. see virConnectGetCapabilities, /capabilities/host/migration_features.
  1481.  
  1482. There are many limitations on migration imposed by the underlying
  1483. technology - for example it may not be possible to migrate between
  1484. different processors even with the same architecture, or between
  1485. different types of hypervisor.
  1486.  
  1487. If the hypervisor supports it, @dxml can be used to alter
  1488. host-specific portions of the domain XML that will be used on
  1489. the destination. For example, it is possible to alter the
  1490. backing filename that is associated with a disk device, in order
  1491. to account for naming differences between source and destination
  1492. in accessing the underlying storage. The migration will fail
  1493. if @dxml would cause any guest-visible changes. Pass None
  1494. if no changes are needed to the XML between source and destination.
  1495. @dxml cannot be used to rename the domain during migration (use
  1496. @dname for that purpose). Domain name in @dxml must match the
  1497. original domain name.
  1498.  
  1499. virDomainFree should be used to free the resources after the
  1500. returned domain object is no longer needed. """
  1501. if dconn is None: dconn__o = None
  1502. else: dconn__o = dconn._o
  1503. ret = libvirtmod.virDomainMigrate2(self._o, dconn__o, dxml, flags, dname, uri, bandwidth)
  1504. if ret is None:raise libvirtError('virDomainMigrate2() failed', dom=self)
  1505. __tmp = virDomain(self,_obj=ret)
  1506. return __tmp
  1507.  
  1508. #
  1509. # virDomain functions from module python
  1510. #
  1511.  
  1512. def migrate3(self, dconn, params, flags=0):
  1513. """Migrate the domain object from its current host to the destination host
  1514. given by dconn (a connection to the destination host). """
  1515. if dconn is None: dconn__o = None
  1516. else: dconn__o = dconn._o
  1517. ret = libvirtmod.virDomainMigrate3(self._o, dconn__o, params, flags)
  1518. if ret is None:raise libvirtError('virDomainMigrate3() failed', dom=self)
  1519. __tmp = virDomain(self,_obj=ret)
  1520. return __tmp
  1521.  
  1522. def migrateGetCompressionCache(self, flags=0):
  1523. """Get current size of the cache (in bytes) used for compressing
  1524. repeatedly transferred memory pages during live migration. """
  1525. ret = libvirtmod.virDomainMigrateGetCompressionCache(self._o, flags)
  1526. return ret
  1527.  
  1528. def migrateGetMaxSpeed(self, flags=0):
  1529. """Get currently configured maximum migration speed for a domain """
  1530. ret = libvirtmod.virDomainMigrateGetMaxSpeed(self._o, flags)
  1531. if ret == -1: raise libvirtError ('virDomainMigrateGetMaxSpeed() failed', dom=self)
  1532. return ret
  1533.  
  1534. #
  1535. # virDomain functions from module libvirt
  1536. #
  1537.  
  1538. def migrateSetCompressionCache(self, cacheSize, flags=0):
  1539. """Sets size of the cache (in bytes) used for compressing repeatedly
  1540. transferred memory pages during live migration. It's supposed to be called
  1541. while the domain is being live-migrated as a reaction to migration progress
  1542. and increasing number of compression cache misses obtained from
  1543. virDomainGetJobStats. """
  1544. ret = libvirtmod.virDomainMigrateSetCompressionCache(self._o, cacheSize, flags)
  1545. if ret == -1: raise libvirtError ('virDomainMigrateSetCompressionCache() failed', dom=self)
  1546. return ret
  1547.  
  1548. def migrateSetMaxDowntime(self, downtime, flags=0):
  1549. """Sets maximum tolerable time for which the domain is allowed to be paused
  1550. at the end of live migration. It's supposed to be called while the domain is
  1551. being live-migrated as a reaction to migration progress. """
  1552. ret = libvirtmod.virDomainMigrateSetMaxDowntime(self._o, downtime, flags)
  1553. if ret == -1: raise libvirtError ('virDomainMigrateSetMaxDowntime() failed', dom=self)
  1554. return ret
  1555.  
  1556. def migrateSetMaxSpeed(self, bandwidth, flags=0):
  1557. """The maximum bandwidth (in MiB/s) that will be used to do migration
  1558. can be specified with the bandwidth parameter. Not all hypervisors
  1559. will support a bandwidth cap """
  1560. ret = libvirtmod.virDomainMigrateSetMaxSpeed(self._o, bandwidth, flags)
  1561. if ret == -1: raise libvirtError ('virDomainMigrateSetMaxSpeed() failed', dom=self)
  1562. return ret
  1563.  
  1564. def migrateToURI(self, duri, flags=0, dname=None, bandwidth=0):
  1565. """Migrate the domain object from its current host to the destination
  1566. host given by duri.
  1567.  
  1568. Flags may be one of more of the following:
  1569. VIR_MIGRATE_LIVE Do not pause the VM during migration
  1570. VIR_MIGRATE_PEER2PEER Direct connection between source & destination hosts
  1571. VIR_MIGRATE_TUNNELLED Tunnel migration data over the libvirt RPC channel
  1572. VIR_MIGRATE_PERSIST_DEST If the migration is successful, persist the domain
  1573. on the destination host.
  1574. VIR_MIGRATE_UNDEFINE_SOURCE If the migration is successful, undefine the
  1575. domain on the source host.
  1576. VIR_MIGRATE_PAUSED Leave the domain suspended on the remote side.
  1577. VIR_MIGRATE_NON_SHARED_DISK Migration with non-shared storage with full
  1578. disk copy
  1579. VIR_MIGRATE_NON_SHARED_INC Migration with non-shared storage with
  1580. incremental disk copy
  1581. VIR_MIGRATE_CHANGE_PROTECTION Protect against domain configuration
  1582. changes during the migration process (set
  1583. automatically when supported).
  1584. VIR_MIGRATE_UNSAFE Force migration even if it is considered unsafe.
  1585. VIR_MIGRATE_OFFLINE Migrate offline
  1586.  
  1587. The operation of this API hinges on the VIR_MIGRATE_PEER2PEER flag.
  1588. If the VIR_MIGRATE_PEER2PEER flag is NOT set, the duri parameter
  1589. takes a hypervisor specific format. The uri_transports element of the
  1590. hypervisor capabilities XML includes details of the supported URI
  1591. schemes. Not all hypervisors will support this mode of migration, so
  1592. if the VIR_MIGRATE_PEER2PEER flag is not set, then it may be necessary
  1593. to use the alternative virDomainMigrate API providing and explicit
  1594. virConnectPtr for the destination host.
  1595.  
  1596. If the VIR_MIGRATE_PEER2PEER flag IS set, the duri parameter
  1597. must be a valid libvirt connection URI, by which the source
  1598. libvirt driver can connect to the destination libvirt.
  1599.  
  1600. VIR_MIGRATE_TUNNELLED requires that VIR_MIGRATE_PEER2PEER be set.
  1601.  
  1602. If you want to copy non-shared storage within migration you
  1603. can use either VIR_MIGRATE_NON_SHARED_DISK or
  1604. VIR_MIGRATE_NON_SHARED_INC as they are mutually exclusive.
  1605.  
  1606. If a hypervisor supports renaming domains during migration,
  1607. the dname parameter specifies the new name for the domain.
  1608. Setting dname to None keeps the domain name the same. If domain
  1609. renaming is not supported by the hypervisor, dname must be None or
  1610. else an error will be returned.
  1611.  
  1612. The maximum bandwidth (in MiB/s) that will be used to do migration
  1613. can be specified with the bandwidth parameter. If set to 0,
  1614. libvirt will choose a suitable default. Some hypervisors do
  1615. not support this feature and will return an error if bandwidth
  1616. is not 0.
  1617.  
  1618. To see which features are supported by the current hypervisor,
  1619. see virConnectGetCapabilities, /capabilities/host/migration_features.
  1620.  
  1621. There are many limitations on migration imposed by the underlying
  1622. technology - for example it may not be possible to migrate between
  1623. different processors even with the same architecture, or between
  1624. different types of hypervisor. """
  1625. ret = libvirtmod.virDomainMigrateToURI(self._o, duri, flags, dname, bandwidth)
  1626. if ret == -1: raise libvirtError ('virDomainMigrateToURI() failed', dom=self)
  1627. return ret
  1628.  
  1629. def migrateToURI2(self, dconnuri=None, miguri=None, dxml=None, flags=0, dname=None, bandwidth=0):
  1630. """Migrate the domain object from its current host to the destination
  1631. host given by duri.
  1632.  
  1633. Flags may be one of more of the following:
  1634. VIR_MIGRATE_LIVE Do not pause the VM during migration
  1635. VIR_MIGRATE_PEER2PEER Direct connection between source & destination hosts
  1636. VIR_MIGRATE_TUNNELLED Tunnel migration data over the libvirt RPC channel
  1637. VIR_MIGRATE_PERSIST_DEST If the migration is successful, persist the domain
  1638. on the destination host.
  1639. VIR_MIGRATE_UNDEFINE_SOURCE If the migration is successful, undefine the
  1640. domain on the source host.
  1641. VIR_MIGRATE_PAUSED Leave the domain suspended on the remote side.
  1642. VIR_MIGRATE_NON_SHARED_DISK Migration with non-shared storage with full
  1643. disk copy
  1644. VIR_MIGRATE_NON_SHARED_INC Migration with non-shared storage with
  1645. incremental disk copy
  1646. VIR_MIGRATE_CHANGE_PROTECTION Protect against domain configuration
  1647. changes during the migration process (set
  1648. automatically when supported).
  1649. VIR_MIGRATE_UNSAFE Force migration even if it is considered unsafe.
  1650. VIR_MIGRATE_OFFLINE Migrate offline
  1651.  
  1652. The operation of this API hinges on the VIR_MIGRATE_PEER2PEER flag.
  1653.  
  1654. If the VIR_MIGRATE_PEER2PEER flag is set, the @dconnuri parameter
  1655. must be a valid libvirt connection URI, by which the source
  1656. libvirt driver can connect to the destination libvirt. If the
  1657. VIR_MIGRATE_PEER2PEER flag is NOT set, then @dconnuri must be
  1658. None.
  1659.  
  1660. If the VIR_MIGRATE_TUNNELLED flag is NOT set, then the @miguri
  1661. parameter allows specification of a URI to use to initiate the
  1662. VM migration. It takes a hypervisor specific format. The uri_transports
  1663. element of the hypervisor capabilities XML includes details of the
  1664. supported URI schemes.
  1665.  
  1666. VIR_MIGRATE_TUNNELLED requires that VIR_MIGRATE_PEER2PEER be set.
  1667.  
  1668. If you want to copy non-shared storage within migration you
  1669. can use either VIR_MIGRATE_NON_SHARED_DISK or
  1670. VIR_MIGRATE_NON_SHARED_INC as they are mutually exclusive.
  1671.  
  1672. If a hypervisor supports changing the configuration of the guest
  1673. during migration, the @dxml parameter specifies the new config
  1674. for the guest. The configuration must include an identical set
  1675. of virtual devices, to ensure a stable guest ABI across migration.
  1676. Only parameters related to host side configuration can be
  1677. changed in the XML. Hypervisors will validate this and refuse to
  1678. allow migration if the provided XML would cause a change in the
  1679. guest ABI,
  1680.  
  1681. If a hypervisor supports renaming domains during migration,
  1682. the dname parameter specifies the new name for the domain.
  1683. Setting dname to None keeps the domain name the same. If domain
  1684. renaming is not supported by the hypervisor, dname must be None or
  1685. else an error will be returned.
  1686.  
  1687. The maximum bandwidth (in MiB/s) that will be used to do migration
  1688. can be specified with the bandwidth parameter. If set to 0,
  1689. libvirt will choose a suitable default. Some hypervisors do
  1690. not support this feature and will return an error if bandwidth
  1691. is not 0.
  1692.  
  1693. To see which features are supported by the current hypervisor,
  1694. see virConnectGetCapabilities, /capabilities/host/migration_features.
  1695.  
  1696. There are many limitations on migration imposed by the underlying
  1697. technology - for example it may not be possible to migrate between
  1698. different processors even with the same architecture, or between
  1699. different types of hypervisor. """
  1700. ret = libvirtmod.virDomainMigrateToURI2(self._o, dconnuri, miguri, dxml, flags, dname, bandwidth)
  1701. if ret == -1: raise libvirtError ('virDomainMigrateToURI2() failed', dom=self)
  1702. return ret
  1703.  
  1704. #
  1705. # virDomain functions from module python
  1706. #
  1707.  
  1708. def migrateToURI3(self, dconnuri, params, flags=0):
  1709. """Migrate the domain object from its current host to the destination host
  1710. given by URI. """
  1711. ret = libvirtmod.virDomainMigrateToURI3(self._o, dconnuri, params, flags)
  1712. if ret == -1: raise libvirtError ('virDomainMigrateToURI3() failed', dom=self)
  1713. return ret
  1714.  
  1715. #
  1716. # virDomain functions from module libvirt
  1717. #
  1718.  
  1719. def name(self):
  1720. """Get the public name for that domain """
  1721. ret = libvirtmod.virDomainGetName(self._o)
  1722. return ret
  1723.  
  1724. #
  1725. # virDomain functions from module python
  1726. #
  1727.  
  1728. def numaParameters(self, flags=0):
  1729. """Get the NUMA parameters """
  1730. ret = libvirtmod.virDomainGetNumaParameters(self._o, flags)
  1731. if ret is None: raise libvirtError ('virDomainGetNumaParameters() failed', dom=self)
  1732. return ret
  1733.  
  1734. #
  1735. # virDomain functions from module libvirt
  1736. #
  1737.  
  1738. def openChannel(self, name, st, flags=0):
  1739. """This opens the host interface associated with a channel device on a
  1740. guest, if the host interface is supported. If @name is given, it
  1741. can match either the device alias (e.g. "channel0"), or the virtio
  1742. target name (e.g. "org.qemu.guest_agent.0"). If @name is omitted,
  1743. then the first channel is opened. The channel is associated with
  1744. the passed in @st stream, which should have been opened in
  1745. non-blocking mode for bi-directional I/O.
  1746.  
  1747. By default, when @flags is 0, the open will fail if libvirt detects
  1748. that the channel is already in use by another client; passing
  1749. VIR_DOMAIN_CHANNEL_FORCE will cause libvirt to forcefully remove the
  1750. other client prior to opening this channel. """
  1751. if st is None: st__o = None
  1752. else: st__o = st._o
  1753. ret = libvirtmod.virDomainOpenChannel(self._o, name, st__o, flags)
  1754. if ret == -1: raise libvirtError ('virDomainOpenChannel() failed', dom=self)
  1755. return ret
  1756.  
  1757. def openConsole(self, dev_name, st, flags=0):
  1758. """This opens the backend associated with a console, serial or
  1759. parallel port device on a guest, if the backend is supported.
  1760. If the @dev_name is omitted, then the first console or serial
  1761. device is opened. The console is associated with the passed
  1762. in @st stream, which should have been opened in non-blocking
  1763. mode for bi-directional I/O.
  1764.  
  1765. By default, when @flags is 0, the open will fail if libvirt
  1766. detects that the console is already in use by another client;
  1767. passing VIR_DOMAIN_CONSOLE_FORCE will cause libvirt to forcefully
  1768. remove the other client prior to opening this console.
  1769.  
  1770. If flag VIR_DOMAIN_CONSOLE_SAFE the console is opened only in the
  1771. case where the hypervisor driver supports safe (mutually exclusive)
  1772. console handling.
  1773.  
  1774. Older servers did not support either flag, and also did not forbid
  1775. simultaneous clients on a console, with potentially confusing results.
  1776. When passing @flags of 0 in order to support a wider range of server
  1777. versions, it is up to the client to ensure mutual exclusion. """
  1778. if st is None: st__o = None
  1779. else: st__o = st._o
  1780. ret = libvirtmod.virDomainOpenConsole(self._o, dev_name, st__o, flags)
  1781. if ret == -1: raise libvirtError ('virDomainOpenConsole() failed', dom=self)
  1782. return ret
  1783.  
  1784. def openGraphics(self, idx, fd, flags=0):
  1785. """This will attempt to connect the file descriptor @fd, to
  1786. the graphics backend of @dom. If @dom has multiple graphics
  1787. backends configured, then @idx will determine which one is
  1788. opened, starting from @idx 0.
  1789.  
  1790. To disable any authentication, pass the VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH
  1791. constant for @flags.
  1792.  
  1793. The caller should use an anonymous socketpair to open
  1794. @fd before invocation.
  1795.  
  1796. This method can only be used when connected to a local
  1797. libvirt hypervisor, over a UNIX domain socket. Attempts
  1798. to use this method over a TCP connection will always fail """
  1799. ret = libvirtmod.virDomainOpenGraphics(self._o, idx, fd, flags)
  1800. if ret == -1: raise libvirtError ('virDomainOpenGraphics() failed', dom=self)
  1801. return ret
  1802.  
  1803. def openGraphicsFD(self, idx, flags=0):
  1804. """This will create a socket pair connected to the graphics backend of @dom.
  1805. One end of the socket will be returned on success, and the other end is
  1806. handed to the hypervisor.
  1807. If @dom has multiple graphics backends configured, then @idx will determine
  1808. which one is opened, starting from @idx 0.
  1809.  
  1810. To disable any authentication, pass the VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH
  1811. constant for @flags.
  1812.  
  1813. This method can only be used when connected to a local
  1814. libvirt hypervisor, over a UNIX domain socket. Attempts
  1815. to use this method over a TCP connection will always fail. """
  1816. ret = libvirtmod.virDomainOpenGraphicsFD(self._o, idx, flags)
  1817. if ret == -1: raise libvirtError ('virDomainOpenGraphicsFD() failed', dom=self)
  1818. return ret
  1819.  
  1820. def pMSuspendForDuration(self, target, duration, flags=0):
  1821. """Attempt to have the guest enter the given @target power management
  1822. suspension level. If @duration is non-zero, also schedule the guest to
  1823. resume normal operation after that many seconds, if nothing else has
  1824. resumed it earlier. Some hypervisors require that @duration be 0, for
  1825. an indefinite suspension.
  1826.  
  1827. Dependent on hypervisor used, this may require a
  1828. guest agent to be available, e.g. QEMU.
  1829.  
  1830. Beware that at least for QEMU, the domain's process will be terminated
  1831. when VIR_NODE_SUSPEND_TARGET_DISK is used and a new process will be
  1832. launched when libvirt is asked to wake up the domain. As a result of
  1833. this, any runtime changes, such as device hotplug or memory settings,
  1834. are lost unless such changes were made with VIR_DOMAIN_AFFECT_CONFIG
  1835. flag. """
  1836. ret = libvirtmod.virDomainPMSuspendForDuration(self._o, target, duration, flags)
  1837. if ret == -1: raise libvirtError ('virDomainPMSuspendForDuration() failed', dom=self)
  1838. return ret
  1839.  
  1840. def pMWakeup(self, flags=0):
  1841. """Inject a wakeup into the guest that previously used
  1842. virDomainPMSuspendForDuration, rather than waiting for the
  1843. previously requested duration (if any) to elapse. """
  1844. ret = libvirtmod.virDomainPMWakeup(self._o, flags)
  1845. if ret == -1: raise libvirtError ('virDomainPMWakeup() failed', dom=self)
  1846. return ret
  1847.  
  1848. #
  1849. # virDomain functions from module python
  1850. #
  1851.  
  1852. def pinEmulator(self, cpumap, flags=0):
  1853. """Dynamically change the real CPUs which can be allocated to the emulator process of a domain.
  1854. This function requires privileged access to the hypervisor. """
  1855. ret = libvirtmod.virDomainPinEmulator(self._o, cpumap, flags)
  1856. if ret == -1: raise libvirtError ('virDomainPinEmulator() failed', dom=self)
  1857. return ret
  1858.  
  1859. def pinVcpu(self, vcpu, cpumap):
  1860. """Dynamically change the real CPUs which can be allocated to a virtual CPU. This function requires privileged access to the hypervisor. """
  1861. ret = libvirtmod.virDomainPinVcpu(self._o, vcpu, cpumap)
  1862. if ret == -1: raise libvirtError ('virDomainPinVcpu() failed', dom=self)
  1863. return ret
  1864.  
  1865. def pinVcpuFlags(self, vcpu, cpumap, flags=0):
  1866. """Dynamically change the real CPUs which can be allocated to a virtual CPU. This function requires privileged access to the hypervisor. """
  1867. ret = libvirtmod.virDomainPinVcpuFlags(self._o, vcpu, cpumap, flags)
  1868. if ret == -1: raise libvirtError ('virDomainPinVcpuFlags() failed', dom=self)
  1869. return ret
  1870.  
  1871. #
  1872. # virDomain functions from module libvirt
  1873. #
  1874.  
  1875. def reboot(self, flags=0):
  1876. """Reboot a domain, the domain object is still usable thereafter, but
  1877. the domain OS is being stopped for a restart.
  1878. Note that the guest OS may ignore the request.
  1879. Additionally, the hypervisor may check and support the domain
  1880. 'on_reboot' XML setting resulting in a domain that shuts down instead
  1881. of rebooting.
  1882.  
  1883. If @flags is set to zero, then the hypervisor will choose the
  1884. method of shutdown it considers best. To have greater control
  1885. pass one or more of the virDomainRebootFlagValues. The order
  1886. in which the hypervisor tries each shutdown method is undefined,
  1887. and a hypervisor is not required to support all methods.
  1888.  
  1889. To use guest agent (VIR_DOMAIN_REBOOT_GUEST_AGENT) the domain XML
  1890. must have <channel> configured.
  1891.  
  1892. Due to implementation limitations in some drivers (the qemu driver,
  1893. for instance) it is not advised to migrate or save a guest that is
  1894. rebooting as a result of this API. Migrating such a guest can lead
  1895. to a plain shutdown on the destination. """
  1896. ret = libvirtmod.virDomainReboot(self._o, flags)
  1897. if ret == -1: raise libvirtError ('virDomainReboot() failed', dom=self)
  1898. return ret
  1899.  
  1900. def reset(self, flags=0):
  1901. """Reset a domain immediately without any guest OS shutdown.
  1902. Reset emulates the power reset button on a machine, where all
  1903. hardware sees the RST line set and reinitializes internal state.
  1904.  
  1905. Note that there is a risk of data loss caused by reset without any
  1906. guest OS shutdown. """
  1907. ret = libvirtmod.virDomainReset(self._o, flags)
  1908. if ret == -1: raise libvirtError ('virDomainReset() failed', dom=self)
  1909. return ret
  1910.  
  1911. def resume(self):
  1912. """Resume a suspended domain, the process is restarted from the state where
  1913. it was frozen by calling virDomainSuspend().
  1914. This function may require privileged access
  1915. Moreover, resume may not be supported if domain is in some
  1916. special state like VIR_DOMAIN_PMSUSPENDED. """
  1917. ret = libvirtmod.virDomainResume(self._o)
  1918. if ret == -1: raise libvirtError ('virDomainResume() failed', dom=self)
  1919. return ret
  1920.  
  1921. #
  1922. # virDomain functions from module python
  1923. #
  1924.  
  1925. def revertToSnapshot(self, snap, flags=0):
  1926. """revert the domain to the given snapshot """
  1927. if snap is None: snap__o = None
  1928. else: snap__o = snap._o
  1929. ret = libvirtmod.virDomainRevertToSnapshot(self._o, snap__o, flags)
  1930. if ret == -1: raise libvirtError ('virDomainRevertToSnapshot() failed', dom=self)
  1931. return ret
  1932.  
  1933. #
  1934. # virDomain functions from module libvirt
  1935. #
  1936.  
  1937. def save(self, to):
  1938. """This method will suspend a domain and save its memory contents to
  1939. a file on disk. After the call, if successful, the domain is not
  1940. listed as running anymore (this ends the life of a transient domain).
  1941. Use virDomainRestore() to restore a domain after saving.
  1942.  
  1943. See virDomainSaveFlags() for more control. Also, a save file can
  1944. be inspected or modified slightly with virDomainSaveImageGetXMLDesc()
  1945. and virDomainSaveImageDefineXML(). """
  1946. ret = libvirtmod.virDomainSave(self._o, to)
  1947. if ret == -1: raise libvirtError ('virDomainSave() failed', dom=self)
  1948. return ret
  1949.  
  1950. def saveFlags(self, to, dxml=None, flags=0):
  1951. """This method will suspend a domain and save its memory contents to
  1952. a file on disk. After the call, if successful, the domain is not
  1953. listed as running anymore (this ends the life of a transient domain).
  1954. Use virDomainRestore() to restore a domain after saving.
  1955.  
  1956. If the hypervisor supports it, @dxml can be used to alter
  1957. host-specific portions of the domain XML that will be used when
  1958. restoring an image. For example, it is possible to alter the
  1959. backing filename that is associated with a disk device, in order to
  1960. prepare for file renaming done as part of backing up the disk
  1961. device while the domain is stopped.
  1962.  
  1963. If @flags includes VIR_DOMAIN_SAVE_BYPASS_CACHE, then libvirt will
  1964. attempt to bypass the file system cache while creating the file, or
  1965. fail if it cannot do so for the given system; this can allow less
  1966. pressure on file system cache, but also risks slowing saves to NFS.
  1967.  
  1968. Normally, the saved state file will remember whether the domain was
  1969. running or paused, and restore defaults to the same state.
  1970. Specifying VIR_DOMAIN_SAVE_RUNNING or VIR_DOMAIN_SAVE_PAUSED in
  1971. @flags will override what state gets saved into the file. These
  1972. two flags are mutually exclusive.
  1973.  
  1974. A save file can be inspected or modified slightly with
  1975. virDomainSaveImageGetXMLDesc() and virDomainSaveImageDefineXML().
  1976.  
  1977. Some hypervisors may prevent this operation if there is a current
  1978. block copy operation; in that case, use virDomainBlockJobAbort()
  1979. to stop the block copy first. """
  1980. ret = libvirtmod.virDomainSaveFlags(self._o, to, dxml, flags)
  1981. if ret == -1: raise libvirtError ('virDomainSaveFlags() failed', dom=self)
  1982. return ret
  1983.  
  1984. #
  1985. # virDomain functions from module python
  1986. #
  1987.  
  1988. def schedulerParameters(self):
  1989. """Get the scheduler parameters, the @params array will be filled with the values. """
  1990. ret = libvirtmod.virDomainGetSchedulerParameters(self._o)
  1991. if ret is None: raise libvirtError ('virDomainGetSchedulerParameters() failed', dom=self)
  1992. return ret
  1993.  
  1994. def schedulerParametersFlags(self, flags=0):
  1995. """Get the scheduler parameters """
  1996. ret = libvirtmod.virDomainGetSchedulerParametersFlags(self._o, flags)
  1997. if ret is None: raise libvirtError ('virDomainGetSchedulerParametersFlags() failed', dom=self)
  1998. return ret
  1999.  
  2000. def schedulerType(self):
  2001. """Get the scheduler type. """
  2002. ret = libvirtmod.virDomainGetSchedulerType(self._o)
  2003. if ret is None: raise libvirtError ('virDomainGetSchedulerType() failed', dom=self)
  2004. return ret
  2005.  
  2006. #
  2007. # virDomain functions from module libvirt
  2008. #
  2009.  
  2010. def screenshot(self, stream, screen, flags=0):
  2011. """Take a screenshot of current domain console as a stream. The image format
  2012. is hypervisor specific. Moreover, some hypervisors supports multiple
  2013. displays per domain. These can be distinguished by @screen argument.
  2014.  
  2015. This call sets up a stream; subsequent use of stream API is necessary
  2016. to transfer actual data, determine how much data is successfully
  2017. transferred, and detect any errors.
  2018.  
  2019. The screen ID is the sequential number of screen. In case of multiple
  2020. graphics cards, heads are enumerated before devices, e.g. having
  2021. two graphics cards, both with four heads, screen ID 5 addresses
  2022. the second head on the second card. """
  2023. if stream is None: stream__o = None
  2024. else: stream__o = stream._o
  2025. ret = libvirtmod.virDomainScreenshot(self._o, stream__o, screen, flags)
  2026. if ret is None: raise libvirtError ('virDomainScreenshot() failed', dom=self)
  2027. return ret
  2028.  
  2029. #
  2030. # virDomain functions from module python
  2031. #
  2032.  
  2033. def securityLabel(self):
  2034. """Extract information about the domain security label. Only the first label will be returned. """
  2035. ret = libvirtmod.virDomainGetSecurityLabel(self._o)
  2036. if ret is None: raise libvirtError ('virDomainGetSecurityLabel() failed', dom=self)
  2037. return ret
  2038.  
  2039. def securityLabelList(self):
  2040. """Extract information about the domain security label. A list of all labels will be returned. """
  2041. ret = libvirtmod.virDomainGetSecurityLabelList(self._o)
  2042. if ret is None: raise libvirtError ('virDomainGetSecurityLabelList() failed', dom=self)
  2043. return ret
  2044.  
  2045. #
  2046. # virDomain functions from module libvirt
  2047. #
  2048.  
  2049. def sendKey(self, codeset, holdtime, keycodes, nkeycodes, flags=0):
  2050. """Send key(s) to the guest. """
  2051. ret = libvirtmod.virDomainSendKey(self._o, codeset, holdtime, keycodes, nkeycodes, flags)
  2052. if ret == -1: raise libvirtError ('virDomainSendKey() failed', dom=self)
  2053. return ret
  2054.  
  2055. def sendProcessSignal(self, pid_value, signum, flags=0):
  2056. """Send a signal to the designated process in the guest
  2057.  
  2058. The signal numbers must be taken from the virDomainProcessSignal
  2059. enum. These will be translated to the corresponding signal
  2060. number for the guest OS, by the guest agent delivering the
  2061. signal. If there is no mapping from virDomainProcessSignal to
  2062. the native OS signals, this API will report an error.
  2063.  
  2064. If @pid_value is an integer greater than zero, it is
  2065. treated as a process ID. If @pid_value is an integer
  2066. less than zero, it is treated as a process group ID.
  2067. All the @pid_value numbers are from the container/guest
  2068. namespace. The value zero is not valid.
  2069.  
  2070. Not all hypervisors will support sending signals to
  2071. arbitrary processes or process groups. If this API is
  2072. implemented the minimum requirement is to be able to
  2073. use @pid_value == 1 (i.e. kill init). No other value is
  2074. required to be supported.
  2075.  
  2076. If the @signum is VIR_DOMAIN_PROCESS_SIGNAL_NOP then this
  2077. API will simply report whether the process is running in
  2078. the container/guest. """
  2079. ret = libvirtmod.virDomainSendProcessSignal(self._o, pid_value, signum, flags)
  2080. if ret == -1: raise libvirtError ('virDomainSendProcessSignal() failed', dom=self)
  2081. return ret
  2082.  
  2083. def setAutostart(self, autostart):
  2084. """Configure the domain to be automatically started
  2085. when the host machine boots. """
  2086. ret = libvirtmod.virDomainSetAutostart(self._o, autostart)
  2087. if ret == -1: raise libvirtError ('virDomainSetAutostart() failed', dom=self)
  2088. return ret
  2089.  
  2090. #
  2091. # virDomain functions from module python
  2092. #
  2093.  
  2094. def setBlkioParameters(self, params, flags=0):
  2095. """Change the blkio tunables """
  2096. ret = libvirtmod.virDomainSetBlkioParameters(self._o, params, flags)
  2097. if ret == -1: raise libvirtError ('virDomainSetBlkioParameters() failed', dom=self)
  2098. return ret
  2099.  
  2100. def setBlockIoTune(self, disk, params, flags=0):
  2101. """Change the I/O tunables for a block device """
  2102. ret = libvirtmod.virDomainSetBlockIoTune(self._o, disk, params, flags)
  2103. if ret == -1: raise libvirtError ('virDomainSetBlockIoTune() failed', dom=self)
  2104. return ret
  2105.  
  2106. def setInterfaceParameters(self, device, params, flags=0):
  2107. """Change the bandwidth tunables for a interface device """
  2108. ret = libvirtmod.virDomainSetInterfaceParameters(self._o, device, params, flags)
  2109. if ret == -1: raise libvirtError ('virDomainSetInterfaceParameters() failed', dom=self)
  2110. return ret
  2111.  
  2112. #
  2113. # virDomain functions from module libvirt
  2114. #
  2115.  
  2116. def setMaxMemory(self, memory):
  2117. """Dynamically change the maximum amount of physical memory allocated to a
  2118. domain. If domain is None, then this change the amount of memory reserved
  2119. to Domain0 i.e. the domain where the application runs.
  2120. This function may require privileged access to the hypervisor.
  2121.  
  2122. This command is hypervisor-specific for whether active, persistent,
  2123. or both configurations are changed; for more control, use
  2124. virDomainSetMemoryFlags(). """
  2125. ret = libvirtmod.virDomainSetMaxMemory(self._o, memory)
  2126. if ret == -1: raise libvirtError ('virDomainSetMaxMemory() failed', dom=self)
  2127. return ret
  2128.  
  2129. def setMemory(self, memory):
  2130. """Dynamically change the target amount of physical memory allocated to a
  2131. domain. If domain is None, then this change the amount of memory reserved
  2132. to Domain0 i.e. the domain where the application runs.
  2133. This function may require privileged access to the hypervisor.
  2134.  
  2135. This command only changes the runtime configuration of the domain,
  2136. so can only be called on an active domain. """
  2137. ret = libvirtmod.virDomainSetMemory(self._o, memory)
  2138. if ret == -1: raise libvirtError ('virDomainSetMemory() failed', dom=self)
  2139. return ret
  2140.  
  2141. def setMemoryFlags(self, memory, flags=0):
  2142. """Dynamically change the target amount of physical memory allocated to a
  2143. domain. If domain is None, then this change the amount of memory reserved
  2144. to Domain0 i.e. the domain where the application runs.
  2145. This function may require privileged access to the hypervisor.
  2146.  
  2147. @flags may include VIR_DOMAIN_AFFECT_LIVE or VIR_DOMAIN_AFFECT_CONFIG.
  2148. Both flags may be set. If VIR_DOMAIN_AFFECT_LIVE is set, the change affects
  2149. a running domain and will fail if domain is not active.
  2150. If VIR_DOMAIN_AFFECT_CONFIG is set, the change affects persistent state,
  2151. and will fail for transient domains. If neither flag is specified
  2152. (that is, @flags is VIR_DOMAIN_AFFECT_CURRENT), then an inactive domain
  2153. modifies persistent setup, while an active domain is hypervisor-dependent
  2154. on whether just live or both live and persistent state is changed.
  2155. If VIR_DOMAIN_MEM_MAXIMUM is set, the change affects domain's maximum memory
  2156. size rather than current memory size.
  2157. Not all hypervisors can support all flag combinations. """
  2158. ret = libvirtmod.virDomainSetMemoryFlags(self._o, memory, flags)
  2159. if ret == -1: raise libvirtError ('virDomainSetMemoryFlags() failed', dom=self)
  2160. return ret
  2161.  
  2162. #
  2163. # virDomain functions from module python
  2164. #
  2165.  
  2166. def setMemoryParameters(self, params, flags=0):
  2167. """Change the memory tunables """
  2168. ret = libvirtmod.virDomainSetMemoryParameters(self._o, params, flags)
  2169. if ret == -1: raise libvirtError ('virDomainSetMemoryParameters() failed', dom=self)
  2170. return ret
  2171.  
  2172. #
  2173. # virDomain functions from module libvirt
  2174. #
  2175.  
  2176. def setMemoryStatsPeriod(self, period, flags=0):
  2177. """Dynamically change the domain memory balloon driver statistics collection
  2178. period. Use 0 to disable and a positive value to enable.
  2179.  
  2180. @flags may include VIR_DOMAIN_AFFECT_LIVE or VIR_DOMAIN_AFFECT_CONFIG.
  2181. Both flags may be set. If VIR_DOMAIN_AFFECT_LIVE is set, the change affects
  2182. a running domain and will fail if domain is not active.
  2183. If VIR_DOMAIN_AFFECT_CONFIG is set, the change affects persistent state,
  2184. and will fail for transient domains. If neither flag is specified
  2185. (that is, @flags is VIR_DOMAIN_AFFECT_CURRENT), then an inactive domain
  2186. modifies persistent setup, while an active domain is hypervisor-dependent
  2187. on whether just live or both live and persistent state is changed.
  2188.  
  2189. Not all hypervisors can support all flag combinations. """
  2190. ret = libvirtmod.virDomainSetMemoryStatsPeriod(self._o, period, flags)
  2191. if ret == -1: raise libvirtError ('virDomainSetMemoryStatsPeriod() failed', dom=self)
  2192. return ret
  2193.  
  2194. def setMetadata(self, type, metadata, key, uri, flags=0):
  2195. """Sets the appropriate domain element given by @type to the
  2196. value of @metadata. A @type of VIR_DOMAIN_METADATA_DESCRIPTION
  2197. is free-form text; VIR_DOMAIN_METADATA_TITLE is free-form, but no
  2198. newlines are permitted, and should be short (although the length is
  2199. not enforced). For these two options @key and @uri are irrelevant and
  2200. must be set to None.
  2201.  
  2202. For type VIR_DOMAIN_METADATA_ELEMENT @metadata must be well-formed
  2203. XML belonging to namespace defined by @uri with local name @key.
  2204.  
  2205. Passing None for @metadata says to remove that element from the
  2206. domain XML (passing the empty string leaves the element present).
  2207.  
  2208. The resulting metadata will be present in virDomainGetXMLDesc(),
  2209. as well as quick access through virDomainGetMetadata().
  2210.  
  2211. @flags controls whether the live domain, persistent configuration,
  2212. or both will be modified. """
  2213. ret = libvirtmod.virDomainSetMetadata(self._o, type, metadata, key, uri, flags)
  2214. if ret == -1: raise libvirtError ('virDomainSetMetadata() failed', dom=self)
  2215. return ret
  2216.  
  2217. #
  2218. # virDomain functions from module python
  2219. #
  2220.  
  2221. def setNumaParameters(self, params, flags=0):
  2222. """Change the NUMA tunables """
  2223. ret = libvirtmod.virDomainSetNumaParameters(self._o, params, flags)
  2224. if ret == -1: raise libvirtError ('virDomainSetNumaParameters() failed', dom=self)
  2225. return ret
  2226.  
  2227. def setSchedulerParameters(self, params):
  2228. """Change the scheduler parameters """
  2229. ret = libvirtmod.virDomainSetSchedulerParameters(self._o, params)
  2230. if ret == -1: raise libvirtError ('virDomainSetSchedulerParameters() failed', dom=self)
  2231. return ret
  2232.  
  2233. def setSchedulerParametersFlags(self, params, flags=0):
  2234. """Change the scheduler parameters """
  2235. ret = libvirtmod.virDomainSetSchedulerParametersFlags(self._o, params, flags)
  2236. if ret == -1: raise libvirtError ('virDomainSetSchedulerParametersFlags() failed', dom=self)
  2237. return ret
  2238.  
  2239. #
  2240. # virDomain functions from module libvirt
  2241. #
  2242.  
  2243. def setVcpus(self, nvcpus):
  2244. """Dynamically change the number of virtual CPUs used by the domain.
  2245. Note that this call may fail if the underlying virtualization hypervisor
  2246. does not support it or if growing the number is arbitrarily limited.
  2247. This function may require privileged access to the hypervisor.
  2248.  
  2249. Note that if this call is executed before the guest has finished booting,
  2250. the guest may fail to process the change.
  2251.  
  2252. This command only changes the runtime configuration of the domain,
  2253. so can only be called on an active domain. It is hypervisor-dependent
  2254. whether it also affects persistent configuration; for more control,
  2255. use virDomainSetVcpusFlags(). """
  2256. ret = libvirtmod.virDomainSetVcpus(self._o, nvcpus)
  2257. if ret == -1: raise libvirtError ('virDomainSetVcpus() failed', dom=self)
  2258. return ret
  2259.  
  2260. def setVcpusFlags(self, nvcpus, flags=0):
  2261. """Dynamically change the number of virtual CPUs used by the domain.
  2262. Note that this call may fail if the underlying virtualization hypervisor
  2263. does not support it or if growing the number is arbitrarily limited.
  2264. This function may require privileged access to the hypervisor.
  2265.  
  2266. @flags may include VIR_DOMAIN_AFFECT_LIVE to affect a running
  2267. domain (which may fail if domain is not active), or
  2268. VIR_DOMAIN_AFFECT_CONFIG to affect the next boot via the XML
  2269. description of the domain. Both flags may be set.
  2270. If neither flag is specified (that is, @flags is VIR_DOMAIN_AFFECT_CURRENT),
  2271. then an inactive domain modifies persistent setup, while an active domain
  2272. is hypervisor-dependent on whether just live or both live and persistent
  2273. state is changed.
  2274.  
  2275. Note that if this call is executed before the guest has finished booting,
  2276. the guest may fail to process the change.
  2277.  
  2278. If @flags includes VIR_DOMAIN_VCPU_MAXIMUM, then
  2279. VIR_DOMAIN_AFFECT_LIVE must be clear, and only the maximum virtual
  2280. CPU limit is altered; generally, this value must be less than or
  2281. equal to virConnectGetMaxVcpus(). Otherwise, this call affects the
  2282. current virtual CPU limit, which must be less than or equal to the
  2283. maximum limit.
  2284.  
  2285. If @flags includes VIR_DOMAIN_VCPU_GUEST, then the state of processors is
  2286. modified inside the guest instead of the hypervisor. This flag can only
  2287. be used with live guests and is incompatible with VIR_DOMAIN_VCPU_MAXIMUM.
  2288. The usage of this flag may require a guest agent configured.
  2289.  
  2290. Not all hypervisors can support all flag combinations. """
  2291. ret = libvirtmod.virDomainSetVcpusFlags(self._o, nvcpus, flags)
  2292. if ret == -1: raise libvirtError ('virDomainSetVcpusFlags() failed', dom=self)
  2293. return ret
  2294.  
  2295. def shutdown(self):
  2296. """Shutdown a domain, the domain object is still usable thereafter, but
  2297. the domain OS is being stopped. Note that the guest OS may ignore the
  2298. request. Additionally, the hypervisor may check and support the domain
  2299. 'on_poweroff' XML setting resulting in a domain that reboots instead of
  2300. shutting down. For guests that react to a shutdown request, the differences
  2301. from virDomainDestroy() are that the guests disk storage will be in a
  2302. stable state rather than having the (virtual) power cord pulled, and
  2303. this command returns as soon as the shutdown request is issued rather
  2304. than blocking until the guest is no longer running.
  2305.  
  2306. If the domain is transient and has any snapshot metadata (see
  2307. virDomainSnapshotNum()), then that metadata will automatically
  2308. be deleted when the domain quits. """
  2309. ret = libvirtmod.virDomainShutdown(self._o)
  2310. if ret == -1: raise libvirtError ('virDomainShutdown() failed', dom=self)
  2311. return ret
  2312.  
  2313. def shutdownFlags(self, flags=0):
  2314. """Shutdown a domain, the domain object is still usable thereafter but
  2315. the domain OS is being stopped. Note that the guest OS may ignore the
  2316. request. Additionally, the hypervisor may check and support the domain
  2317. 'on_poweroff' XML setting resulting in a domain that reboots instead of
  2318. shutting down. For guests that react to a shutdown request, the differences
  2319. from virDomainDestroy() are that the guest's disk storage will be in a
  2320. stable state rather than having the (virtual) power cord pulled, and
  2321. this command returns as soon as the shutdown request is issued rather
  2322. than blocking until the guest is no longer running.
  2323.  
  2324. If the domain is transient and has any snapshot metadata (see
  2325. virDomainSnapshotNum()), then that metadata will automatically
  2326. be deleted when the domain quits.
  2327.  
  2328. If @flags is set to zero, then the hypervisor will choose the
  2329. method of shutdown it considers best. To have greater control
  2330. pass one or more of the virDomainShutdownFlagValues. The order
  2331. in which the hypervisor tries each shutdown method is undefined,
  2332. and a hypervisor is not required to support all methods.
  2333.  
  2334. To use guest agent (VIR_DOMAIN_SHUTDOWN_GUEST_AGENT) the domain XML
  2335. must have <channel> configured. """
  2336. ret = libvirtmod.virDomainShutdownFlags(self._o, flags)
  2337. if ret == -1: raise libvirtError ('virDomainShutdownFlags() failed', dom=self)
  2338. return ret
  2339.  
  2340. def snapshotCreateXML(self, xmlDesc, flags=0):
  2341. """Creates a new snapshot of a domain based on the snapshot xml
  2342. contained in xmlDesc.
  2343.  
  2344. If @flags is 0, the domain can be active, in which case the
  2345. snapshot will be a system checkpoint (both disk state and runtime
  2346. VM state such as RAM contents), where reverting to the snapshot is
  2347. the same as resuming from hibernation (TCP connections may have
  2348. timed out, but everything else picks up where it left off); or
  2349. the domain can be inactive, in which case the snapshot includes
  2350. just the disk state prior to booting. The newly created snapshot
  2351. becomes current (see virDomainSnapshotCurrent()), and is a child
  2352. of any previous current snapshot.
  2353.  
  2354. If @flags includes VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE, then this
  2355. is a request to reinstate snapshot metadata that was previously
  2356. discarded, rather than creating a new snapshot. This can be used
  2357. to recreate a snapshot hierarchy on a destination, then remove it
  2358. on the source, in order to allow migration (since migration
  2359. normally fails if snapshot metadata still remains on the source
  2360. machine). When redefining snapshot metadata, the current snapshot
  2361. will not be altered unless the VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT
  2362. flag is also present. It is an error to request the
  2363. VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT flag without
  2364. VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE. On some hypervisors,
  2365. redefining an existing snapshot can be used to alter host-specific
  2366. portions of the domain XML to be used during revert (such as
  2367. backing filenames associated with disk devices), but must not alter
  2368. guest-visible layout. When redefining a snapshot name that does
  2369. not exist, the hypervisor may validate that reverting to the
  2370. snapshot appears to be possible (for example, disk images have
  2371. snapshot contents by the requested name). Not all hypervisors
  2372. support these flags.
  2373.  
  2374. If @flags includes VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA, then the
  2375. domain's disk images are modified according to @xmlDesc, but then
  2376. the just-created snapshot has its metadata deleted. This flag is
  2377. incompatible with VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE.
  2378.  
  2379. If @flags includes VIR_DOMAIN_SNAPSHOT_CREATE_HALT, then the domain
  2380. will be inactive after the snapshot completes, regardless of whether
  2381. it was active before; otherwise, a running domain will still be
  2382. running after the snapshot. This flag is invalid on transient domains,
  2383. and is incompatible with VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE.
  2384.  
  2385. If @flags includes VIR_DOMAIN_SNAPSHOT_CREATE_LIVE, then the domain
  2386. is not paused while creating the snapshot. This increases the size
  2387. of the memory dump file, but reduces downtime of the guest while
  2388. taking the snapshot. Some hypervisors only support this flag during
  2389. external checkpoints.
  2390.  
  2391. If @flags includes VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY, then the
  2392. snapshot will be limited to the disks described in @xmlDesc, and no
  2393. VM state will be saved. For an active guest, the disk image may be
  2394. inconsistent (as if power had been pulled), and specifying this
  2395. with the VIR_DOMAIN_SNAPSHOT_CREATE_HALT flag risks data loss.
  2396.  
  2397. If @flags includes VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE, then the
  2398. libvirt will attempt to use guest agent to freeze and thaw all
  2399. file systems in use within domain OS. However, if the guest agent
  2400. is not present, an error is thrown. Moreover, this flag requires
  2401. VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY to be passed as well.
  2402.  
  2403. By default, if the snapshot involves external files, and any of the
  2404. destination files already exist as a non-empty regular file, the
  2405. snapshot is rejected to avoid losing contents of those files.
  2406. However, if @flags includes VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT,
  2407. then the destination files must be pre-created manually with
  2408. the correct image format and metadata including backing store path
  2409. (this allows a management app to pre-create files with relative backing
  2410. file names, rather than the default of creating with absolute backing
  2411. file names). Note that setting incorrect metadata in the pre-created
  2412. image may lead to the VM being unable to start.
  2413.  
  2414. Be aware that although libvirt prefers to report errors up front with
  2415. no other effect, some hypervisors have certain types of failures where
  2416. the overall command can easily fail even though the guest configuration
  2417. was partially altered (for example, if a disk snapshot request for two
  2418. disks fails on the second disk, but the first disk alteration cannot be
  2419. rolled back). If this API call fails, it is therefore normally
  2420. necessary to follow up with virDomainGetXMLDesc() and check each disk
  2421. to determine if any partial changes occurred. However, if @flags
  2422. contains VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC, then libvirt guarantees
  2423. that this command will not alter any disks unless the entire set of
  2424. changes can be done atomically, making failure recovery simpler (note
  2425. that it is still possible to fail after disks have changed, but only
  2426. in the much rarer cases of running out of memory or disk space).
  2427.  
  2428. Some hypervisors may prevent this operation if there is a current
  2429. block copy operation; in that case, use virDomainBlockJobAbort()
  2430. to stop the block copy first.
  2431.  
  2432. virDomainSnapshotFree should be used to free the resources after the
  2433. snapshot object is no longer needed. """
  2434. ret = libvirtmod.virDomainSnapshotCreateXML(self._o, xmlDesc, flags)
  2435. if ret is None:raise libvirtError('virDomainSnapshotCreateXML() failed', dom=self)
  2436. __tmp = virDomainSnapshot(self,_obj=ret)
  2437. return __tmp
  2438.  
  2439. def snapshotCurrent(self, flags=0):
  2440. """Get the current snapshot for a domain, if any.
  2441.  
  2442. virDomainSnapshotFree should be used to free the resources after the
  2443. snapshot object is no longer needed. """
  2444. ret = libvirtmod.virDomainSnapshotCurrent(self._o, flags)
  2445. if ret is None:raise libvirtError('virDomainSnapshotCurrent() failed', dom=self)
  2446. __tmp = virDomainSnapshot(self,_obj=ret)
  2447. return __tmp
  2448.  
  2449. #
  2450. # virDomain functions from module python
  2451. #
  2452.  
  2453. def snapshotListNames(self, flags=0):
  2454. """collect the list of snapshot names for the given domain """
  2455. ret = libvirtmod.virDomainSnapshotListNames(self._o, flags)
  2456. if ret is None: raise libvirtError ('virDomainSnapshotListNames() failed', dom=self)
  2457. return ret
  2458.  
  2459. #
  2460. # virDomain functions from module libvirt
  2461. #
  2462.  
  2463. def snapshotLookupByName(self, name, flags=0):
  2464. """Try to lookup a domain snapshot based on its name. """
  2465. ret = libvirtmod.virDomainSnapshotLookupByName(self._o, name, flags)
  2466. if ret is None:raise libvirtError('virDomainSnapshotLookupByName() failed', dom=self)
  2467. __tmp = virDomainSnapshot(self,_obj=ret)
  2468. return __tmp
  2469.  
  2470. def snapshotNum(self, flags=0):
  2471. """Provides the number of domain snapshots for this domain.
  2472.  
  2473. By default, this command covers all snapshots; it is also possible to
  2474. limit things to just snapshots with no parents, when @flags includes
  2475. VIR_DOMAIN_SNAPSHOT_LIST_ROOTS. Additional filters are provided in
  2476. groups, where each group contains bits that describe mutually exclusive
  2477. attributes of a snapshot, and where all bits within a group describe
  2478. all possible snapshots. Some hypervisors might reject explicit bits
  2479. from a group where the hypervisor cannot make a distinction. For a
  2480. group supported by a given hypervisor, the behavior when no bits of a
  2481. group are set is identical to the behavior when all bits in that group
  2482. are set. When setting bits from more than one group, it is possible to
  2483. select an impossible combination, in that case a hypervisor may return
  2484. either 0 or an error.
  2485.  
  2486. The first group of @flags is VIR_DOMAIN_SNAPSHOT_LIST_LEAVES and
  2487. VIR_DOMAIN_SNAPSHOT_LIST_NO_LEAVES, to filter based on snapshots that
  2488. have no further children (a leaf snapshot).
  2489.  
  2490. The next group of @flags is VIR_DOMAIN_SNAPSHOT_LIST_METADATA and
  2491. VIR_DOMAIN_SNAPSHOT_LIST_NO_METADATA, for filtering snapshots based on
  2492. whether they have metadata that would prevent the removal of the last
  2493. reference to a domain.
  2494.  
  2495. The next group of @flags is VIR_DOMAIN_SNAPSHOT_LIST_INACTIVE,
  2496. VIR_DOMAIN_SNAPSHOT_LIST_ACTIVE, and VIR_DOMAIN_SNAPSHOT_LIST_DISK_ONLY,
  2497. for filtering snapshots based on what domain state is tracked by the
  2498. snapshot.
  2499.  
  2500. The next group of @flags is VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL and
  2501. VIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL, for filtering snapshots based on
  2502. whether the snapshot is stored inside the disk images or as
  2503. additional files. """
  2504. ret = libvirtmod.virDomainSnapshotNum(self._o, flags)
  2505. if ret == -1: raise libvirtError ('virDomainSnapshotNum() failed', dom=self)
  2506. return ret
  2507.  
  2508. #
  2509. # virDomain functions from module python
  2510. #
  2511.  
  2512. def state(self, flags=0):
  2513. """Extract domain state. """
  2514. ret = libvirtmod.virDomainGetState(self._o, flags)
  2515. if ret is None: raise libvirtError ('virDomainGetState() failed', dom=self)
  2516. return ret
  2517.  
  2518. #
  2519. # virDomain functions from module libvirt
  2520. #
  2521.  
  2522. def suspend(self):
  2523. """Suspends an active domain, the process is frozen without further access
  2524. to CPU resources and I/O but the memory used by the domain at the
  2525. hypervisor level will stay allocated. Use virDomainResume() to reactivate
  2526. the domain.
  2527. This function may require privileged access.
  2528. Moreover, suspend may not be supported if domain is in some
  2529. special state like VIR_DOMAIN_PMSUSPENDED. """
  2530. ret = libvirtmod.virDomainSuspend(self._o)
  2531. if ret == -1: raise libvirtError ('virDomainSuspend() failed', dom=self)
  2532. return ret
  2533.  
  2534. def undefine(self):
  2535. """Undefine a domain. If the domain is running, it's converted to
  2536. transient domain, without stopping it. If the domain is inactive,
  2537. the domain configuration is removed.
  2538.  
  2539. If the domain has a managed save image (see
  2540. virDomainHasManagedSaveImage()), or if it is inactive and has any
  2541. snapshot metadata (see virDomainSnapshotNum()), then the undefine will
  2542. fail. See virDomainUndefineFlags() for more control. """
  2543. ret = libvirtmod.virDomainUndefine(self._o)
  2544. if ret == -1: raise libvirtError ('virDomainUndefine() failed', dom=self)
  2545. return ret
  2546.  
  2547. def undefineFlags(self, flags=0):
  2548. """Undefine a domain. If the domain is running, it's converted to
  2549. transient domain, without stopping it. If the domain is inactive,
  2550. the domain configuration is removed.
  2551.  
  2552. If the domain has a managed save image (see virDomainHasManagedSaveImage()),
  2553. then including VIR_DOMAIN_UNDEFINE_MANAGED_SAVE in @flags will also remove
  2554. that file, and omitting the flag will cause the undefine process to fail.
  2555.  
  2556. If the domain is inactive and has any snapshot metadata (see
  2557. virDomainSnapshotNum()), then including
  2558. VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA in @flags will also remove
  2559. that metadata. Omitting the flag will cause the undefine of an
  2560. inactive domain to fail. Active snapshots will retain snapshot
  2561. metadata until the (now-transient) domain halts, regardless of
  2562. whether this flag is present. On hypervisors where snapshots do
  2563. not use libvirt metadata, this flag has no effect. """
  2564. ret = libvirtmod.virDomainUndefineFlags(self._o, flags)
  2565. if ret == -1: raise libvirtError ('virDomainUndefineFlags() failed', dom=self)
  2566. return ret
  2567.  
  2568. def updateDeviceFlags(self, xml, flags=0):
  2569. """Change a virtual device on a domain, using the flags parameter
  2570. to control how the device is changed. VIR_DOMAIN_AFFECT_CURRENT
  2571. specifies that the device change is made based on current domain
  2572. state. VIR_DOMAIN_AFFECT_LIVE specifies that the device shall be
  2573. changed on the active domain instance only and is not added to the
  2574. persisted domain configuration. VIR_DOMAIN_AFFECT_CONFIG
  2575. specifies that the device shall be changed on the persisted domain
  2576. configuration only. Note that the target hypervisor must return an
  2577. error if unable to satisfy flags. E.g. the hypervisor driver will
  2578. return failure if LIVE is specified but it only supports modifying the
  2579. persisted device allocation.
  2580.  
  2581. This method is used for actions such changing CDROM/Floppy device
  2582. media, altering the graphics configuration such as password,
  2583. reconfiguring the NIC device backend connectivity, etc. """
  2584. ret = libvirtmod.virDomainUpdateDeviceFlags(self._o, xml, flags)
  2585. if ret == -1: raise libvirtError ('virDomainUpdateDeviceFlags() failed', dom=self)
  2586. return ret
  2587.  
  2588. #
  2589. # virDomain functions from module python
  2590. #
  2591.  
  2592. def vcpuPinInfo(self, flags=0):
  2593. """Query the CPU affinity setting of all virtual CPUs of domain """
  2594. ret = libvirtmod.virDomainGetVcpuPinInfo(self._o, flags)
  2595. if ret is None: raise libvirtError ('virDomainGetVcpuPinInfo() failed', dom=self)
  2596. return ret
  2597.  
  2598. def vcpus(self):
  2599. """Extract information about virtual CPUs of domain, store it in info array and also in cpumaps if this pointer is'nt None. """
  2600. ret = libvirtmod.virDomainGetVcpus(self._o)
  2601. if ret == -1: raise libvirtError ('virDomainGetVcpus() failed', dom=self)
  2602. return ret
  2603.  
  2604. #
  2605. # virDomain functions from module libvirt
  2606. #
  2607.  
  2608. def vcpusFlags(self, flags=0):
  2609. """Query the number of virtual CPUs used by the domain. Note that
  2610. this call may fail if the underlying virtualization hypervisor does
  2611. not support it. This function may require privileged access to the
  2612. hypervisor.
  2613.  
  2614. If @flags includes VIR_DOMAIN_AFFECT_LIVE, this will query a
  2615. running domain (which will fail if domain is not active); if
  2616. it includes VIR_DOMAIN_AFFECT_CONFIG, this will query the XML
  2617. description of the domain. It is an error to set both flags.
  2618. If neither flag is set (that is, VIR_DOMAIN_AFFECT_CURRENT),
  2619. then the configuration queried depends on whether the domain
  2620. is currently running.
  2621.  
  2622. If @flags includes VIR_DOMAIN_VCPU_MAXIMUM, then the maximum
  2623. virtual CPU limit is queried. Otherwise, this call queries the
  2624. current virtual CPU count.
  2625.  
  2626. If @flags includes VIR_DOMAIN_VCPU_GUEST, then the state of the processors
  2627. is queried in the guest instead of the hypervisor. This flag is only usable
  2628. on live domains. Guest agent may be needed for this flag to be available. """
  2629. ret = libvirtmod.virDomainGetVcpusFlags(self._o, flags)
  2630. if ret == -1: raise libvirtError ('virDomainGetVcpusFlags() failed', dom=self)
  2631. return ret
  2632.  
  2633. #
  2634. # virDomain methods from virDomain.py (hand coded)
  2635. #
  2636. def listAllSnapshots(self, flags=0):
  2637. """List all snapshots and returns a list of snapshot objects"""
  2638. ret = libvirtmod.virDomainListAllSnapshots(self._o, flags)
  2639. if ret is None:
  2640. raise libvirtError("virDomainListAllSnapshots() failed", conn=self)
  2641.  
  2642. retlist = list()
  2643. for snapptr in ret:
  2644. retlist.append(virDomainSnapshot(self, _obj=snapptr))
  2645.  
  2646. return retlist
  2647.  
  2648.  
  2649. def createWithFiles(self, files, flags=0):
  2650. """Launch a defined domain. If the call succeeds the domain moves from the
  2651. defined to the running domains pools.
  2652.  
  2653. @files provides an array of file descriptors which will be
  2654. made available to the 'init' process of the guest. The file
  2655. handles exposed to the guest will be renumbered to start
  2656. from 3 (ie immediately following stderr). This is only
  2657. supported for guests which use container based virtualization
  2658. technology.
  2659.  
  2660. If the VIR_DOMAIN_START_PAUSED flag is set, or if the guest domain
  2661. has a managed save image that requested paused state (see
  2662. virDomainManagedSave()) the guest domain will be started, but its
  2663. CPUs will remain paused. The CPUs can later be manually started
  2664. using virDomainResume(). In all other cases, the guest domain will
  2665. be running.
  2666.  
  2667. If the VIR_DOMAIN_START_AUTODESTROY flag is set, the guest
  2668. domain will be automatically destroyed when the virConnectPtr
  2669. object is finally released. This will also happen if the
  2670. client application crashes / loses its connection to the
  2671. libvirtd daemon. Any domains marked for auto destroy will
  2672. block attempts at migration, save-to-file, or snapshots.
  2673.  
  2674. If the VIR_DOMAIN_START_BYPASS_CACHE flag is set, and there is a
  2675. managed save file for this domain (created by virDomainManagedSave()),
  2676. then libvirt will attempt to bypass the file system cache while restoring
  2677. the file, or fail if it cannot do so for the given system; this can allow
  2678. less pressure on file system cache, but also risks slowing loads from NFS.
  2679.  
  2680. If the VIR_DOMAIN_START_FORCE_BOOT flag is set, then any managed save
  2681. file for this domain is discarded, and the domain boots from scratch. """
  2682. ret = libvirtmod.virDomainCreateWithFiles(self._o, files, flags)
  2683. if ret == -1: raise libvirtError ('virDomainCreateWithFiles() failed', dom=self)
  2684. return ret
  2685.  
  2686. def fsFreeze(self, mountpoints=None, flags=0):
  2687. """Freeze specified filesystems within the guest """
  2688. ret = libvirtmod.virDomainFSFreeze(self._o, mountpoints, flags)
  2689. if ret == -1: raise libvirtError ('virDomainFSFreeze() failed', dom=self)
  2690. return ret
  2691.  
  2692. def fsThaw(self, mountpoints=None, flags=0):
  2693. """Thaw specified filesystems within the guest """
  2694. ret = libvirtmod.virDomainFSThaw(self._o, mountpoints, flags)
  2695. if ret == -1: raise libvirtError ('virDomainFSThaw() failed', dom=self)
  2696. return ret
  2697.  
  2698. def getTime(self, flags=0):
  2699. """Extract information about guest time """
  2700. ret = libvirtmod.virDomainGetTime(self._o, flags)
  2701. if ret == -1: raise libvirtError ('virDomainGetTime() failed', dom=self)
  2702. return ret
  2703.  
  2704. def setTime(self, time=None, flags=0):
  2705. """Set guest time to the given value. @time is a dict conatining
  2706. 'seconds' field for seconds and 'nseconds' field for nanosecons """
  2707. ret = libvirtmod.virDomainSetTime(self._o, time, flags)
  2708. if ret == -1: raise libvirtError ('virDomainSetTime() failed', dom=self)
  2709. return ret
  2710.  
  2711. class virNetwork(object):
  2712. def __init__(self, conn, _obj=None):
  2713. self._conn = conn
  2714. self._o = _obj
  2715.  
  2716. def __del__(self):
  2717. if self._o is not None:
  2718. libvirtmod.virNetworkFree(self._o)
  2719. self._o = None
  2720.  
  2721. def connect(self):
  2722. return self._conn
  2723.  
  2724. #
  2725. # virNetwork functions from module python
  2726. #
  2727.  
  2728. def DHCPLeases(self, mac=None, flags=0):
  2729. """Returns a list of dhcp leases for interfaces connected to the given virtual network """
  2730. ret = libvirtmod.virNetworkGetDHCPLeases(self._o, mac, flags)
  2731. if ret is None: raise libvirtError ('virNetworkGetDHCPLeases() failed', net=self)
  2732. return ret
  2733.  
  2734. def UUID(self):
  2735. """Extract the UUID unique Identifier of a network. """
  2736. ret = libvirtmod.virNetworkGetUUID(self._o)
  2737. if ret is None: raise libvirtError ('virNetworkGetUUID() failed', net=self)
  2738. return ret
  2739.  
  2740. def UUIDString(self):
  2741. """Fetch globally unique ID of the network as a string. """
  2742. ret = libvirtmod.virNetworkGetUUIDString(self._o)
  2743. if ret is None: raise libvirtError ('virNetworkGetUUIDString() failed', net=self)
  2744. return ret
  2745.  
  2746. #
  2747. # virNetwork functions from module libvirt
  2748. #
  2749.  
  2750. def XMLDesc(self, flags=0):
  2751. """Provide an XML description of the network. The description may be reused
  2752. later to relaunch the network with virNetworkCreateXML().
  2753.  
  2754. Normally, if a network included a physical function, the output includes
  2755. all virtual functions tied to that physical interface. If @flags includes
  2756. VIR_NETWORK_XML_INACTIVE, then the expansion of virtual interfaces is
  2757. not performed. """
  2758. ret = libvirtmod.virNetworkGetXMLDesc(self._o, flags)
  2759. if ret is None: raise libvirtError ('virNetworkGetXMLDesc() failed', net=self)
  2760. return ret
  2761.  
  2762. #
  2763. # virNetwork functions from module python
  2764. #
  2765.  
  2766. def autostart(self):
  2767. """Extract the autostart flag for a network. """
  2768. ret = libvirtmod.virNetworkGetAutostart(self._o)
  2769. if ret == -1: raise libvirtError ('virNetworkGetAutostart() failed', net=self)
  2770. return ret
  2771.  
  2772. #
  2773. # virNetwork functions from module libvirt
  2774. #
  2775.  
  2776. def bridgeName(self):
  2777. """Provides a bridge interface name to which a domain may connect
  2778. a network interface in order to join the network. """
  2779. ret = libvirtmod.virNetworkGetBridgeName(self._o)
  2780. if ret is None: raise libvirtError ('virNetworkGetBridgeName() failed', net=self)
  2781. return ret
  2782.  
  2783. def create(self):
  2784. """Create and start a defined network. If the call succeed the network
  2785. moves from the defined to the running networks pools. """
  2786. ret = libvirtmod.virNetworkCreate(self._o)
  2787. if ret == -1: raise libvirtError ('virNetworkCreate() failed', net=self)
  2788. return ret
  2789.  
  2790. def destroy(self):
  2791. """Destroy the network object. The running instance is shutdown if not down
  2792. already and all resources used by it are given back to the hypervisor. This
  2793. does not free the associated virNetworkPtr object.
  2794. This function may require privileged access """
  2795. ret = libvirtmod.virNetworkDestroy(self._o)
  2796. if ret == -1: raise libvirtError ('virNetworkDestroy() failed', net=self)
  2797. return ret
  2798.  
  2799. def isActive(self):
  2800. """Determine if the network is currently running """
  2801. ret = libvirtmod.virNetworkIsActive(self._o)
  2802. if ret == -1: raise libvirtError ('virNetworkIsActive() failed', net=self)
  2803. return ret
  2804.  
  2805. def isPersistent(self):
  2806. """Determine if the network has a persistent configuration
  2807. which means it will still exist after shutting down """
  2808. ret = libvirtmod.virNetworkIsPersistent(self._o)
  2809. if ret == -1: raise libvirtError ('virNetworkIsPersistent() failed', net=self)
  2810. return ret
  2811.  
  2812. def name(self):
  2813. """Get the public name for that network """
  2814. ret = libvirtmod.virNetworkGetName(self._o)
  2815. return ret
  2816.  
  2817. def setAutostart(self, autostart):
  2818. """Configure the network to be automatically started
  2819. when the host machine boots. """
  2820. ret = libvirtmod.virNetworkSetAutostart(self._o, autostart)
  2821. if ret == -1: raise libvirtError ('virNetworkSetAutostart() failed', net=self)
  2822. return ret
  2823.  
  2824. def undefine(self):
  2825. """Undefine a network but does not stop it if it is running """
  2826. ret = libvirtmod.virNetworkUndefine(self._o)
  2827. if ret == -1: raise libvirtError ('virNetworkUndefine() failed', net=self)
  2828. return ret
  2829.  
  2830. def update(self, command, section, parentIndex, xml, flags=0):
  2831. """Update the definition of an existing network, either its live
  2832. running state, its persistent configuration, or both. """
  2833. ret = libvirtmod.virNetworkUpdate(self._o, command, section, parentIndex, xml, flags)
  2834. if ret == -1: raise libvirtError ('virNetworkUpdate() failed', net=self)
  2835. return ret
  2836.  
  2837. class virInterface(object):
  2838. def __init__(self, conn, _obj=None):
  2839. self._conn = conn
  2840. self._o = _obj
  2841.  
  2842. def __del__(self):
  2843. if self._o is not None:
  2844. libvirtmod.virInterfaceFree(self._o)
  2845. self._o = None
  2846.  
  2847. def connect(self):
  2848. return self._conn
  2849.  
  2850. #
  2851. # virInterface functions from module libvirt
  2852. #
  2853.  
  2854. def MACString(self):
  2855. """Get the MAC for an interface as string. For more information about
  2856. MAC see RFC4122. """
  2857. ret = libvirtmod.virInterfaceGetMACString(self._o)
  2858. if ret is None: raise libvirtError ('virInterfaceGetMACString() failed', net=self)
  2859. return ret
  2860.  
  2861. def XMLDesc(self, flags=0):
  2862. """VIR_INTERFACE_XML_INACTIVE - return the static configuration,
  2863. suitable for use redefining the
  2864. interface via virInterfaceDefineXML()
  2865.  
  2866. Provide an XML description of the interface. If
  2867. VIR_INTERFACE_XML_INACTIVE is set, the description may be reused
  2868. later to redefine the interface with virInterfaceDefineXML(). If it
  2869. is not set, the ip address and netmask will be the current live
  2870. setting of the interface, not the settings from the config files. """
  2871. ret = libvirtmod.virInterfaceGetXMLDesc(self._o, flags)
  2872. if ret is None: raise libvirtError ('virInterfaceGetXMLDesc() failed', net=self)
  2873. return ret
  2874.  
  2875. def create(self, flags=0):
  2876. """Activate an interface (i.e. call "ifup").
  2877.  
  2878. If there was an open network config transaction at the time this
  2879. interface was defined (that is, if virInterfaceChangeBegin() had
  2880. been called), the interface will be brought back down (and then
  2881. undefined) if virInterfaceChangeRollback() is called. """
  2882. ret = libvirtmod.virInterfaceCreate(self._o, flags)
  2883. if ret == -1: raise libvirtError ('virInterfaceCreate() failed', net=self)
  2884. return ret
  2885.  
  2886. def destroy(self, flags=0):
  2887. """deactivate an interface (ie call "ifdown")
  2888. This does not remove the interface from the config, and
  2889. does not free the associated virInterfacePtr object.
  2890.  
  2891. If there is an open network config transaction at the time this
  2892. interface is destroyed (that is, if virInterfaceChangeBegin() had
  2893. been called), and if the interface is later undefined and then
  2894. virInterfaceChangeRollback() is called, the restoral of the
  2895. interface definition will also bring the interface back up. """
  2896. ret = libvirtmod.virInterfaceDestroy(self._o, flags)
  2897. if ret == -1: raise libvirtError ('virInterfaceDestroy() failed', net=self)
  2898. return ret
  2899.  
  2900. def isActive(self):
  2901. """Determine if the interface is currently running """
  2902. ret = libvirtmod.virInterfaceIsActive(self._o)
  2903. if ret == -1: raise libvirtError ('virInterfaceIsActive() failed', net=self)
  2904. return ret
  2905.  
  2906. def name(self):
  2907. """Get the public name for that interface """
  2908. ret = libvirtmod.virInterfaceGetName(self._o)
  2909. return ret
  2910.  
  2911. def undefine(self):
  2912. """Undefine an interface, ie remove it from the config.
  2913. This does not free the associated virInterfacePtr object.
  2914.  
  2915. Normally this change in the interface configuration is
  2916. permanent/persistent, but if virInterfaceChangeBegin() has been
  2917. previously called (i.e. if an interface config transaction is
  2918. open), the removal of the interface definition will only become
  2919. permanent if virInterfaceChangeCommit() is called prior to the next
  2920. reboot of the system running libvirtd. Prior to that time, the
  2921. definition can be explicitly restored using
  2922. virInterfaceChangeRollback(), or will be automatically restored
  2923. during the next reboot of the system running libvirtd. """
  2924. ret = libvirtmod.virInterfaceUndefine(self._o)
  2925. if ret == -1: raise libvirtError ('virInterfaceUndefine() failed', net=self)
  2926. return ret
  2927.  
  2928. class virStoragePool(object):
  2929. def __init__(self, conn, _obj=None):
  2930. self._conn = conn
  2931. if not isinstance(conn, virConnect):
  2932. self._conn = conn._conn
  2933. self._o = _obj
  2934.  
  2935. def __del__(self):
  2936. if self._o is not None:
  2937. libvirtmod.virStoragePoolFree(self._o)
  2938. self._o = None
  2939.  
  2940. def connect(self):
  2941. return self._conn
  2942.  
  2943. #
  2944. # virStoragePool functions from module python
  2945. #
  2946.  
  2947. def UUID(self):
  2948. """Extract the UUID unique Identifier of a storage pool. """
  2949. ret = libvirtmod.virStoragePoolGetUUID(self._o)
  2950. if ret is None: raise libvirtError ('virStoragePoolGetUUID() failed', pool=self)
  2951. return ret
  2952.  
  2953. def UUIDString(self):
  2954. """Fetch globally unique ID of the storage pool as a string. """
  2955. ret = libvirtmod.virStoragePoolGetUUIDString(self._o)
  2956. if ret is None: raise libvirtError ('virStoragePoolGetUUIDString() failed', pool=self)
  2957. return ret
  2958.  
  2959. #
  2960. # virStoragePool functions from module libvirt
  2961. #
  2962.  
  2963. def XMLDesc(self, flags=0):
  2964. """Fetch an XML document describing all aspects of the
  2965. storage pool. This is suitable for later feeding back
  2966. into the virStoragePoolCreateXML method. """
  2967. ret = libvirtmod.virStoragePoolGetXMLDesc(self._o, flags)
  2968. if ret is None: raise libvirtError ('virStoragePoolGetXMLDesc() failed', pool=self)
  2969. return ret
  2970.  
  2971. #
  2972. # virStoragePool functions from module python
  2973. #
  2974.  
  2975. def autostart(self):
  2976. """Extract the autostart flag for a storage pool """
  2977. ret = libvirtmod.virStoragePoolGetAutostart(self._o)
  2978. if ret == -1: raise libvirtError ('virStoragePoolGetAutostart() failed', pool=self)
  2979. return ret
  2980.  
  2981. #
  2982. # virStoragePool functions from module libvirt
  2983. #
  2984.  
  2985. def build(self, flags=0):
  2986. """Currently only filesystem pool accepts flags VIR_STORAGE_POOL_BUILD_OVERWRITE
  2987. and VIR_STORAGE_POOL_BUILD_NO_OVERWRITE.
  2988.  
  2989. Build the underlying storage pool """
  2990. ret = libvirtmod.virStoragePoolBuild(self._o, flags)
  2991. if ret == -1: raise libvirtError ('virStoragePoolBuild() failed', pool=self)
  2992. return ret
  2993.  
  2994. def create(self, flags=0):
  2995. """Starts an inactive storage pool """
  2996. ret = libvirtmod.virStoragePoolCreate(self._o, flags)
  2997. if ret == -1: raise libvirtError ('virStoragePoolCreate() failed', pool=self)
  2998. return ret
  2999.  
  3000. def createXML(self, xmlDesc, flags=0):
  3001. """Create a storage volume within a pool based
  3002. on an XML description. Not all pools support
  3003. creation of volumes.
  3004.  
  3005. Since 1.0.1 VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA
  3006. in flags can be used to get higher performance with
  3007. qcow2 image files which don't support full preallocation,
  3008. by creating a sparse image file with metadata.
  3009.  
  3010. virStorageVolFree should be used to free the resources after the
  3011. storage volume object is no longer needed. """
  3012. ret = libvirtmod.virStorageVolCreateXML(self._o, xmlDesc, flags)
  3013. if ret is None:raise libvirtError('virStorageVolCreateXML() failed', pool=self)
  3014. __tmp = virStorageVol(self, _obj=ret)
  3015. return __tmp
  3016.  
  3017. def createXMLFrom(self, xmlDesc, clonevol, flags=0):
  3018. """Create a storage volume in the parent pool, using the
  3019. 'clonevol' volume as input. Information for the new
  3020. volume (name, perms) are passed via a typical volume
  3021. XML description.
  3022.  
  3023. Since 1.0.1 VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA
  3024. in flags can be used to get higher performance with
  3025. qcow2 image files which don't support full preallocation,
  3026. by creating a sparse image file with metadata.
  3027.  
  3028. virStorageVolFree should be used to free the resources after the
  3029. storage volume object is no longer needed. """
  3030. if clonevol is None: clonevol__o = None
  3031. else: clonevol__o = clonevol._o
  3032. ret = libvirtmod.virStorageVolCreateXMLFrom(self._o, xmlDesc, clonevol__o, flags)
  3033. if ret is None:raise libvirtError('virStorageVolCreateXMLFrom() failed', pool=self)
  3034. __tmp = virStorageVol(self, _obj=ret)
  3035. return __tmp
  3036.  
  3037. def delete(self, flags=0):
  3038. """Delete the underlying pool resources. This is
  3039. a non-recoverable operation. The virStoragePoolPtr object
  3040. itself is not free'd. """
  3041. ret = libvirtmod.virStoragePoolDelete(self._o, flags)
  3042. if ret == -1: raise libvirtError ('virStoragePoolDelete() failed', pool=self)
  3043. return ret
  3044.  
  3045. def destroy(self):
  3046. """Destroy an active storage pool. This will deactivate the
  3047. pool on the host, but keep any persistent config associated
  3048. with it. If it has a persistent config it can later be
  3049. restarted with virStoragePoolCreate(). This does not free
  3050. the associated virStoragePoolPtr object. """
  3051. ret = libvirtmod.virStoragePoolDestroy(self._o)
  3052. if ret == -1: raise libvirtError ('virStoragePoolDestroy() failed', pool=self)
  3053. return ret
  3054.  
  3055. #
  3056. # virStoragePool functions from module python
  3057. #
  3058.  
  3059. def info(self):
  3060. """Extract information about a storage pool. Note that if the connection used to get the domain is limited only a partial set of the information can be extracted. """
  3061. ret = libvirtmod.virStoragePoolGetInfo(self._o)
  3062. if ret is None: raise libvirtError ('virStoragePoolGetInfo() failed', pool=self)
  3063. return ret
  3064.  
  3065. #
  3066. # virStoragePool functions from module libvirt
  3067. #
  3068.  
  3069. def isActive(self):
  3070. """Determine if the storage pool is currently running """
  3071. ret = libvirtmod.virStoragePoolIsActive(self._o)
  3072. if ret == -1: raise libvirtError ('virStoragePoolIsActive() failed', pool=self)
  3073. return ret
  3074.  
  3075. def isPersistent(self):
  3076. """Determine if the storage pool has a persistent configuration
  3077. which means it will still exist after shutting down """
  3078. ret = libvirtmod.virStoragePoolIsPersistent(self._o)
  3079. if ret == -1: raise libvirtError ('virStoragePoolIsPersistent() failed', pool=self)
  3080. return ret
  3081.  
  3082. #
  3083. # virStoragePool functions from module python
  3084. #
  3085.  
  3086. def listVolumes(self):
  3087. """list the storage volumes, stores the pointers to the names in @names """
  3088. ret = libvirtmod.virStoragePoolListVolumes(self._o)
  3089. if ret is None: raise libvirtError ('virStoragePoolListVolumes() failed', pool=self)
  3090. return ret
  3091.  
  3092. #
  3093. # virStoragePool functions from module libvirt
  3094. #
  3095.  
  3096. def name(self):
  3097. """Fetch the locally unique name of the storage pool """
  3098. ret = libvirtmod.virStoragePoolGetName(self._o)
  3099. return ret
  3100.  
  3101. def numOfVolumes(self):
  3102. """Fetch the number of storage volumes within a pool """
  3103. ret = libvirtmod.virStoragePoolNumOfVolumes(self._o)
  3104. if ret == -1: raise libvirtError ('virStoragePoolNumOfVolumes() failed', pool=self)
  3105. return ret
  3106.  
  3107. def refresh(self, flags=0):
  3108. """Request that the pool refresh its list of volumes. This may
  3109. involve communicating with a remote server, and/or initializing
  3110. new devices at the OS layer """
  3111. ret = libvirtmod.virStoragePoolRefresh(self._o, flags)
  3112. if ret == -1: raise libvirtError ('virStoragePoolRefresh() failed', pool=self)
  3113. return ret
  3114.  
  3115. def setAutostart(self, autostart):
  3116. """Sets the autostart flag """
  3117. ret = libvirtmod.virStoragePoolSetAutostart(self._o, autostart)
  3118. if ret == -1: raise libvirtError ('virStoragePoolSetAutostart() failed', pool=self)
  3119. return ret
  3120.  
  3121. def storageVolLookupByName(self, name):
  3122. """Fetch a pointer to a storage volume based on its name
  3123. within a pool
  3124.  
  3125. virStorageVolFree should be used to free the resources after the
  3126. storage volume object is no longer needed. """
  3127. ret = libvirtmod.virStorageVolLookupByName(self._o, name)
  3128. if ret is None:raise libvirtError('virStorageVolLookupByName() failed', pool=self)
  3129. __tmp = virStorageVol(self, _obj=ret)
  3130. return __tmp
  3131.  
  3132. def undefine(self):
  3133. """Undefine an inactive storage pool """
  3134. ret = libvirtmod.virStoragePoolUndefine(self._o)
  3135. if ret == -1: raise libvirtError ('virStoragePoolUndefine() failed', pool=self)
  3136. return ret
  3137.  
  3138. #
  3139. # virStoragePool methods from virStoragePool.py (hand coded)
  3140. #
  3141. def listAllVolumes(self, flags=0):
  3142. """List all storage volumes and returns a list of storage volume objects"""
  3143. ret = libvirtmod.virStoragePoolListAllVolumes(self._o, flags)
  3144. if ret is None:
  3145. raise libvirtError("virStoragePoolListAllVolumes() failed", conn=self)
  3146.  
  3147. retlist = list()
  3148. for volptr in ret:
  3149. retlist.append(virStorageVol(self, _obj=volptr))
  3150.  
  3151. return retlist
  3152.  
  3153. class virStorageVol(object):
  3154. def __init__(self, conn, _obj=None):
  3155. self._conn = conn
  3156. if not isinstance(conn, virConnect):
  3157. self._conn = conn._conn
  3158. self._o = _obj
  3159.  
  3160. def __del__(self):
  3161. if self._o is not None:
  3162. libvirtmod.virStorageVolFree(self._o)
  3163. self._o = None
  3164.  
  3165. def connect(self):
  3166. return self._conn
  3167.  
  3168. #
  3169. # virStorageVol functions from module libvirt
  3170. #
  3171.  
  3172. def XMLDesc(self, flags=0):
  3173. """Fetch an XML document describing all aspects of
  3174. the storage volume """
  3175. ret = libvirtmod.virStorageVolGetXMLDesc(self._o, flags)
  3176. if ret is None: raise libvirtError ('virStorageVolGetXMLDesc() failed', vol=self)
  3177. return ret
  3178.  
  3179. def delete(self, flags=0):
  3180. """Delete the storage volume from the pool """
  3181. ret = libvirtmod.virStorageVolDelete(self._o, flags)
  3182. if ret == -1: raise libvirtError ('virStorageVolDelete() failed', vol=self)
  3183. return ret
  3184.  
  3185. def download(self, stream, offset, length, flags=0):
  3186. """Download the content of the volume as a stream. If @length
  3187. is zero, then the remaining contents of the volume after
  3188. @offset will be downloaded.
  3189.  
  3190. This call sets up an asynchronous stream; subsequent use of
  3191. stream APIs is necessary to transfer the actual data,
  3192. determine how much data is successfully transferred, and
  3193. detect any errors. The results will be unpredictable if
  3194. another active stream is writing to the storage volume. """
  3195. if stream is None: stream__o = None
  3196. else: stream__o = stream._o
  3197. ret = libvirtmod.virStorageVolDownload(self._o, stream__o, offset, length, flags)
  3198. if ret == -1: raise libvirtError ('virStorageVolDownload() failed', vol=self)
  3199. return ret
  3200.  
  3201. #
  3202. # virStorageVol functions from module python
  3203. #
  3204.  
  3205. def info(self):
  3206. """Extract information about a storage volume. Note that if the connection used to get the domain is limited only a partial set of the information can be extracted. """
  3207. ret = libvirtmod.virStorageVolGetInfo(self._o)
  3208. if ret is None: raise libvirtError ('virStorageVolGetInfo() failed', vol=self)
  3209. return ret
  3210.  
  3211. #
  3212. # virStorageVol functions from module libvirt
  3213. #
  3214.  
  3215. def key(self):
  3216. """Fetch the storage volume key. This is globally
  3217. unique, so the same volume will have the same
  3218. key no matter what host it is accessed from """
  3219. ret = libvirtmod.virStorageVolGetKey(self._o)
  3220. if ret is None: raise libvirtError ('virStorageVolGetKey() failed', vol=self)
  3221. return ret
  3222.  
  3223. def name(self):
  3224. """Fetch the storage volume name. This is unique
  3225. within the scope of a pool """
  3226. ret = libvirtmod.virStorageVolGetName(self._o)
  3227. return ret
  3228.  
  3229. def path(self):
  3230. """Fetch the storage volume path. Depending on the pool
  3231. configuration this is either persistent across hosts,
  3232. or dynamically assigned at pool startup. Consult
  3233. pool documentation for information on getting the
  3234. persistent naming """
  3235. ret = libvirtmod.virStorageVolGetPath(self._o)
  3236. if ret is None: raise libvirtError ('virStorageVolGetPath() failed', vol=self)
  3237. return ret
  3238.  
  3239. def resize(self, capacity, flags=0):
  3240. """Changes the capacity of the storage volume @vol to @capacity. The
  3241. operation will fail if the new capacity requires allocation that would
  3242. exceed the remaining free space in the parent pool. The contents of
  3243. the new capacity will appear as all zero bytes. The capacity value will
  3244. be rounded to the granularity supported by the hypervisor.
  3245.  
  3246. Normally, the operation will attempt to affect capacity with a minimum
  3247. impact on allocation (that is, the default operation favors a sparse
  3248. resize). If @flags contains VIR_STORAGE_VOL_RESIZE_ALLOCATE, then the
  3249. operation will ensure that allocation is sufficient for the new
  3250. capacity; this may make the operation take noticeably longer.
  3251.  
  3252. Normally, the operation treats @capacity as the new size in bytes;
  3253. but if @flags contains VIR_STORAGE_VOL_RESIZE_DELTA, then @capacity
  3254. represents the size difference to add to the current size. It is
  3255. up to the storage pool implementation whether unaligned requests are
  3256. rounded up to the next valid boundary, or rejected.
  3257.  
  3258. Normally, this operation should only be used to enlarge capacity;
  3259. but if @flags contains VIR_STORAGE_VOL_RESIZE_SHRINK, it is possible to
  3260. attempt a reduction in capacity even though it might cause data loss.
  3261. If VIR_STORAGE_VOL_RESIZE_DELTA is also present, then @capacity is
  3262. subtracted from the current size; without it, @capacity represents
  3263. the absolute new size regardless of whether it is larger or smaller
  3264. than the current size. """
  3265. ret = libvirtmod.virStorageVolResize(self._o, capacity, flags)
  3266. if ret == -1: raise libvirtError ('virStorageVolResize() failed', vol=self)
  3267. return ret
  3268.  
  3269. def storagePoolLookupByVolume(self):
  3270. """Fetch a storage pool which contains a particular volume
  3271.  
  3272. virStoragePoolFree should be used to free the resources after the
  3273. storage pool object is no longer needed. """
  3274. ret = libvirtmod.virStoragePoolLookupByVolume(self._o)
  3275. if ret is None:raise libvirtError('virStoragePoolLookupByVolume() failed', vol=self)
  3276. __tmp = virStoragePool(self, _obj=ret)
  3277. return __tmp
  3278.  
  3279. def upload(self, stream, offset, length, flags=0):
  3280. """Upload new content to the volume from a stream. This call
  3281. will fail if @offset + @length exceeds the size of the
  3282. volume. Otherwise, if @length is non-zero, an error
  3283. will be raised if an attempt is made to upload greater
  3284. than @length bytes of data.
  3285.  
  3286. This call sets up an asynchronous stream; subsequent use of
  3287. stream APIs is necessary to transfer the actual data,
  3288. determine how much data is successfully transferred, and
  3289. detect any errors. The results will be unpredictable if
  3290. another active stream is writing to the storage volume.
  3291.  
  3292. When the data stream is closed whether the upload is successful
  3293. or not the target storage pool will be refreshed to reflect pool
  3294. and volume changes as a result of the upload. Depending on
  3295. the target volume storage backend and the source stream type
  3296. for a successful upload, the target volume may take on the
  3297. characteristics from the source stream such as format type,
  3298. capacity, and allocation. """
  3299. if stream is None: stream__o = None
  3300. else: stream__o = stream._o
  3301. ret = libvirtmod.virStorageVolUpload(self._o, stream__o, offset, length, flags)
  3302. if ret == -1: raise libvirtError ('virStorageVolUpload() failed', vol=self)
  3303. return ret
  3304.  
  3305. def wipe(self, flags=0):
  3306. """Ensure data previously on a volume is not accessible to future reads """
  3307. ret = libvirtmod.virStorageVolWipe(self._o, flags)
  3308. if ret == -1: raise libvirtError ('virStorageVolWipe() failed', vol=self)
  3309. return ret
  3310.  
  3311. def wipePattern(self, algorithm, flags=0):
  3312. """Similar to virStorageVolWipe, but one can choose
  3313. between different wiping algorithms. """
  3314. ret = libvirtmod.virStorageVolWipePattern(self._o, algorithm, flags)
  3315. if ret == -1: raise libvirtError ('virStorageVolWipePattern() failed', vol=self)
  3316. return ret
  3317.  
  3318. class virConnect(object):
  3319. def __init__(self, _obj=None):
  3320. self._o = _obj
  3321.  
  3322. #
  3323. # virConnect functions from module python
  3324. #
  3325.  
  3326. def baselineCPU(self, xmlCPUs, flags=0):
  3327. """Computes the most feature-rich CPU which is compatible with all given host CPUs. """
  3328. ret = libvirtmod.virConnectBaselineCPU(self._o, xmlCPUs, flags)
  3329. if ret is None: raise libvirtError ('virConnectBaselineCPU() failed', conn=self)
  3330. return ret
  3331.  
  3332. #
  3333. # virConnect functions from module libvirt
  3334. #
  3335.  
  3336. def changeBegin(self, flags=0):
  3337. """This function creates a restore point to which one can return
  3338. later by calling virInterfaceChangeRollback(). This function should
  3339. be called before any transaction with interface configuration.
  3340. Once it is known that a new configuration works, it can be committed via
  3341. virInterfaceChangeCommit(), which frees the restore point.
  3342.  
  3343. If virInterfaceChangeBegin() is called when a transaction is
  3344. already opened, this function will fail, and a
  3345. VIR_ERR_INVALID_OPERATION will be logged. """
  3346. ret = libvirtmod.virInterfaceChangeBegin(self._o, flags)
  3347. if ret == -1: raise libvirtError ('virInterfaceChangeBegin() failed', conn=self)
  3348. return ret
  3349.  
  3350. def changeCommit(self, flags=0):
  3351. """This commits the changes made to interfaces and frees the restore point
  3352. created by virInterfaceChangeBegin().
  3353.  
  3354. If virInterfaceChangeCommit() is called when a transaction is not
  3355. opened, this function will fail, and a VIR_ERR_INVALID_OPERATION
  3356. will be logged. """
  3357. ret = libvirtmod.virInterfaceChangeCommit(self._o, flags)
  3358. if ret == -1: raise libvirtError ('virInterfaceChangeCommit() failed', conn=self)
  3359. return ret
  3360.  
  3361. def changeRollback(self, flags=0):
  3362. """This cancels changes made to interfaces settings by restoring previous
  3363. state created by virInterfaceChangeBegin().
  3364.  
  3365. If virInterfaceChangeRollback() is called when a transaction is not
  3366. opened, this function will fail, and a VIR_ERR_INVALID_OPERATION
  3367. will be logged. """
  3368. ret = libvirtmod.virInterfaceChangeRollback(self._o, flags)
  3369. if ret == -1: raise libvirtError ('virInterfaceChangeRollback() failed', conn=self)
  3370. return ret
  3371.  
  3372. def close(self):
  3373. """This function closes the connection to the Hypervisor. This should
  3374. not be called if further interaction with the Hypervisor are needed
  3375. especially if there is running domain which need further monitoring by
  3376. the application.
  3377.  
  3378. Connections are reference counted; the count is explicitly
  3379. increased by the initial open (virConnectOpen, virConnectOpenAuth,
  3380. and the like) as well as virConnectRef; it is also temporarily
  3381. increased by other API that depend on the connection remaining
  3382. alive. The open and every virConnectRef call should have a
  3383. matching virConnectClose, and all other references will be released
  3384. after the corresponding operation completes. """
  3385. ret = libvirtmod.virConnectClose(self._o)
  3386. self._o = None
  3387. if ret == -1: raise libvirtError ('virConnectClose() failed', conn=self)
  3388. return ret
  3389.  
  3390. def compareCPU(self, xmlDesc, flags=0):
  3391. """Compares the given CPU description with the host CPU """
  3392. ret = libvirtmod.virConnectCompareCPU(self._o, xmlDesc, flags)
  3393. if ret == -1: raise libvirtError ('virConnectCompareCPU() failed', conn=self)
  3394. return ret
  3395.  
  3396. def createLinux(self, xmlDesc, flags=0):
  3397. """Deprecated after 0.4.6.
  3398. Renamed to virDomainCreateXML() providing identical functionality.
  3399. This existing name will left indefinitely for API compatibility. """
  3400. ret = libvirtmod.virDomainCreateLinux(self._o, xmlDesc, flags)
  3401. if ret is None:raise libvirtError('virDomainCreateLinux() failed', conn=self)
  3402. __tmp = virDomain(self,_obj=ret)
  3403. return __tmp
  3404.  
  3405. def createXML(self, xmlDesc, flags=0):
  3406. """Launch a new guest domain, based on an XML description similar
  3407. to the one returned by virDomainGetXMLDesc()
  3408. This function may require privileged access to the hypervisor.
  3409. The domain is not persistent, so its definition will disappear when it
  3410. is destroyed, or if the host is restarted (see virDomainDefineXML() to
  3411. define persistent domains).
  3412.  
  3413. If the VIR_DOMAIN_START_PAUSED flag is set, the guest domain
  3414. will be started, but its CPUs will remain paused. The CPUs
  3415. can later be manually started using virDomainResume.
  3416.  
  3417. If the VIR_DOMAIN_START_AUTODESTROY flag is set, the guest
  3418. domain will be automatically destroyed when the virConnectPtr
  3419. object is finally released. This will also happen if the
  3420. client application crashes / loses its connection to the
  3421. libvirtd daemon. Any domains marked for auto destroy will
  3422. block attempts at migration, save-to-file, or snapshots.
  3423.  
  3424. virDomainFree should be used to free the resources after the
  3425. domain object is no longer needed. """
  3426. ret = libvirtmod.virDomainCreateXML(self._o, xmlDesc, flags)
  3427. if ret is None:raise libvirtError('virDomainCreateXML() failed', conn=self)
  3428. __tmp = virDomain(self,_obj=ret)
  3429. return __tmp
  3430.  
  3431. def defineXML(self, xml):
  3432. """Define a domain, but does not start it.
  3433. This definition is persistent, until explicitly undefined with
  3434. virDomainUndefine(). A previous definition for this domain would be
  3435. overridden if it already exists.
  3436.  
  3437. Some hypervisors may prevent this operation if there is a current
  3438. block copy operation on a transient domain with the same id as the
  3439. domain being defined; in that case, use virDomainBlockJobAbort() to
  3440. stop the block copy first.
  3441.  
  3442. virDomainFree should be used to free the resources after the
  3443. domain object is no longer needed. """
  3444. ret = libvirtmod.virDomainDefineXML(self._o, xml)
  3445. if ret is None:raise libvirtError('virDomainDefineXML() failed', conn=self)
  3446. __tmp = virDomain(self,_obj=ret)
  3447. return __tmp
  3448.  
  3449. def domainXMLFromNative(self, nativeFormat, nativeConfig, flags=0):
  3450. """Reads native configuration data describing a domain, and
  3451. generates libvirt domain XML. The format of the native
  3452. data is hypervisor dependant. """
  3453. ret = libvirtmod.virConnectDomainXMLFromNative(self._o, nativeFormat, nativeConfig, flags)
  3454. if ret is None: raise libvirtError ('virConnectDomainXMLFromNative() failed', conn=self)
  3455. return ret
  3456.  
  3457. def domainXMLToNative(self, nativeFormat, domainXml, flags=0):
  3458. """Reads a domain XML configuration document, and generates
  3459. a native configuration file describing the domain.
  3460. The format of the native data is hypervisor dependant. """
  3461. ret = libvirtmod.virConnectDomainXMLToNative(self._o, nativeFormat, domainXml, flags)
  3462. if ret is None: raise libvirtError ('virConnectDomainXMLToNative() failed', conn=self)
  3463. return ret
  3464.  
  3465. def findStoragePoolSources(self, type, srcSpec, flags=0):
  3466. """Talks to a storage backend and attempts to auto-discover the set of
  3467. available storage pool sources. e.g. For iSCSI this would be a set of
  3468. iSCSI targets. For NFS this would be a list of exported paths. The
  3469. srcSpec (optional for some storage pool types, e.g. local ones) is
  3470. an instance of the storage pool's source element specifying where
  3471. to look for the pools.
  3472.  
  3473. srcSpec is not required for some types (e.g., those querying
  3474. local storage resources only) """
  3475. ret = libvirtmod.virConnectFindStoragePoolSources(self._o, type, srcSpec, flags)
  3476. if ret is None: raise libvirtError ('virConnectFindStoragePoolSources() failed', conn=self)
  3477. return ret
  3478.  
  3479. #
  3480. # virConnect functions from module python
  3481. #
  3482.  
  3483. def getCPUMap(self, flags=0):
  3484. """Get node CPU information """
  3485. ret = libvirtmod.virNodeGetCPUMap(self._o, flags)
  3486. if ret is None: raise libvirtError ('virNodeGetCPUMap() failed', conn=self)
  3487. return ret
  3488.  
  3489. def getCPUModelNames(self, arch, flags=0):
  3490. """Get the list of supported CPU models. """
  3491. ret = libvirtmod.virConnectGetCPUModelNames(self._o, arch, flags)
  3492. if ret is None: raise libvirtError ('virConnectGetCPUModelNames() failed', conn=self)
  3493. return ret
  3494.  
  3495. def getCPUStats(self, cpuNum, flags=0):
  3496. """Extract node's CPU statistics. """
  3497. ret = libvirtmod.virNodeGetCPUStats(self._o, cpuNum, flags)
  3498. if ret is None: raise libvirtError ('virNodeGetCPUStats() failed', conn=self)
  3499. return ret
  3500.  
  3501. #
  3502. # virConnect functions from module libvirt
  3503. #
  3504.  
  3505. def getCapabilities(self):
  3506. """Provides capabilities of the hypervisor / driver. """
  3507. ret = libvirtmod.virConnectGetCapabilities(self._o)
  3508. if ret is None: raise libvirtError ('virConnectGetCapabilities() failed', conn=self)
  3509. return ret
  3510.  
  3511. #
  3512. # virConnect functions from module python
  3513. #
  3514.  
  3515. def getCellsFreeMemory(self, startCell, maxCells):
  3516. """Returns the available memory for a list of cells """
  3517. ret = libvirtmod.virNodeGetCellsFreeMemory(self._o, startCell, maxCells)
  3518. if ret is None: raise libvirtError ('virNodeGetCellsFreeMemory() failed', conn=self)
  3519. return ret
  3520.  
  3521. #
  3522. # virConnect functions from module libvirt
  3523. #
  3524.  
  3525. def getDomainCapabilities(self, emulatorbin, arch, machine, virttype, flags=0):
  3526. """Prior creating a domain (for instance via virDomainCreateXML
  3527. or virDomainDefineXML) it may be suitable to know what the
  3528. underlying emulator and/or libvirt is capable of. For
  3529. instance, if host, libvirt and qemu is capable of VFIO
  3530. passthrough and so on. """
  3531. ret = libvirtmod.virConnectGetDomainCapabilities(self._o, emulatorbin, arch, machine, virttype, flags)
  3532. if ret is None: raise libvirtError ('virConnectGetDomainCapabilities() failed', conn=self)
  3533. return ret
  3534.  
  3535. def getFreeMemory(self):
  3536. """provides the free memory available on the Node
  3537. Note: most libvirt APIs provide memory sizes in kibibytes, but in this
  3538. function the returned value is in bytes. Divide by 1024 as necessary. """
  3539. ret = libvirtmod.virNodeGetFreeMemory(self._o)
  3540. return ret
  3541.  
  3542. #
  3543. # virConnect functions from module python
  3544. #
  3545.  
  3546. def getFreePages(self, pages, startCell, maxCells, flags=0):
  3547. """Returns the number of available pages for a list of cells and page sizes """
  3548. ret = libvirtmod.virNodeGetFreePages(self._o, pages, startCell, maxCells, flags)
  3549. if ret is None: raise libvirtError ('virNodeGetFreePages() failed', conn=self)
  3550. return ret
  3551.  
  3552. #
  3553. # virConnect functions from module libvirt
  3554. #
  3555.  
  3556. def getHostname(self):
  3557. """This returns a system hostname on which the hypervisor is
  3558. running (based on the result of the gethostname system call, but
  3559. possibly expanded to a fully-qualified domain name via getaddrinfo).
  3560. If we are connected to a remote system, then this returns the
  3561. hostname of the remote system. """
  3562. ret = libvirtmod.virConnectGetHostname(self._o)
  3563. if ret is None: raise libvirtError ('virConnectGetHostname() failed', conn=self)
  3564. return ret
  3565.  
  3566. #
  3567. # virConnect functions from module python
  3568. #
  3569.  
  3570. def getInfo(self):
  3571. """Extract hardware information about the Node. Note that the memory size is reported in MiB instead of KiB. """
  3572. ret = libvirtmod.virNodeGetInfo(self._o)
  3573. if ret is None: raise libvirtError ('virNodeGetInfo() failed', conn=self)
  3574. return ret
  3575.  
  3576. def getLibVersion(self):
  3577. """Returns the libvirt version of the connection host """
  3578. ret = libvirtmod.virConnectGetLibVersion(self._o)
  3579. if ret == -1: raise libvirtError ('virConnectGetLibVersion() failed', conn=self)
  3580. return ret
  3581.  
  3582. #
  3583. # virConnect functions from module libvirt
  3584. #
  3585.  
  3586. def getMaxVcpus(self, type):
  3587. """Provides the maximum number of virtual CPUs supported for a guest VM of a
  3588. specific type. The 'type' parameter here corresponds to the 'type'
  3589. attribute in the <domain> element of the XML. """
  3590. ret = libvirtmod.virConnectGetMaxVcpus(self._o, type)
  3591. if ret == -1: raise libvirtError ('virConnectGetMaxVcpus() failed', conn=self)
  3592. return ret
  3593.  
  3594. #
  3595. # virConnect functions from module python
  3596. #
  3597.  
  3598. def getMemoryParameters(self, flags=0):
  3599. """Get the node memory parameters """
  3600. ret = libvirtmod.virNodeGetMemoryParameters(self._o, flags)
  3601. if ret is None: raise libvirtError ('virNodeGetMemoryParameters() failed', conn=self)
  3602. return ret
  3603.  
  3604. def getMemoryStats(self, cellNum, flags=0):
  3605. """Extract node's memory statistics. """
  3606. ret = libvirtmod.virNodeGetMemoryStats(self._o, cellNum, flags)
  3607. if ret is None: raise libvirtError ('virNodeGetMemoryStats() failed', conn=self)
  3608. return ret
  3609.  
  3610. def getSecurityModel(self):
  3611. """Extract information about the host security model """
  3612. ret = libvirtmod.virNodeGetSecurityModel(self._o)
  3613. if ret is None: raise libvirtError ('virNodeGetSecurityModel() failed', conn=self)
  3614. return ret
  3615.  
  3616. #
  3617. # virConnect functions from module libvirt
  3618. #
  3619.  
  3620. def getSysinfo(self, flags=0):
  3621. """This returns the XML description of the sysinfo details for the
  3622. host on which the hypervisor is running, in the same format as the
  3623. <sysinfo> element of a domain XML. This information is generally
  3624. available only for hypervisors running with root privileges. """
  3625. ret = libvirtmod.virConnectGetSysinfo(self._o, flags)
  3626. if ret is None: raise libvirtError ('virConnectGetSysinfo() failed', conn=self)
  3627. return ret
  3628.  
  3629. def getType(self):
  3630. """Get the name of the Hypervisor driver used. This is merely the driver
  3631. name; for example, both KVM and QEMU guests are serviced by the
  3632. driver for the qemu:// URI, so a return of "QEMU" does not indicate
  3633. whether KVM acceleration is present. For more details about the
  3634. hypervisor, use virConnectGetCapabilities(). """
  3635. ret = libvirtmod.virConnectGetType(self._o)
  3636. if ret is None: raise libvirtError ('virConnectGetType() failed', conn=self)
  3637. return ret
  3638.  
  3639. def getURI(self):
  3640. """This returns the URI (name) of the hypervisor connection.
  3641. Normally this is the same as or similar to the string passed
  3642. to the virConnectOpen/virConnectOpenReadOnly call, but
  3643. the driver may make the URI canonical. If name == None
  3644. was passed to virConnectOpen, then the driver will return
  3645. a non-None URI which can be used to connect to the same
  3646. hypervisor later. """
  3647. ret = libvirtmod.virConnectGetURI(self._o)
  3648. if ret is None: raise libvirtError ('virConnectGetURI() failed', conn=self)
  3649. return ret
  3650.  
  3651. #
  3652. # virConnect functions from module python
  3653. #
  3654.  
  3655. def getVersion(self):
  3656. """Returns the running hypervisor version of the connection host """
  3657. ret = libvirtmod.virConnectGetVersion(self._o)
  3658. if ret == -1: raise libvirtError ('virConnectGetVersion() failed', conn=self)
  3659. return ret
  3660.  
  3661. #
  3662. # virConnect functions from module libvirt
  3663. #
  3664.  
  3665. def interfaceDefineXML(self, xml, flags=0):
  3666. """Define an interface (or modify existing interface configuration).
  3667.  
  3668. Normally this change in the interface configuration is immediately
  3669. permanent/persistent, but if virInterfaceChangeBegin() has been
  3670. previously called (i.e. if an interface config transaction is
  3671. open), the new interface definition will only become permanent if
  3672. virInterfaceChangeCommit() is called prior to the next reboot of
  3673. the system running libvirtd. Prior to that time, it can be
  3674. explicitly removed using virInterfaceChangeRollback(), or will be
  3675. automatically removed during the next reboot of the system running
  3676. libvirtd.
  3677.  
  3678. virInterfaceFree should be used to free the resources after the
  3679. interface object is no longer needed. """
  3680. ret = libvirtmod.virInterfaceDefineXML(self._o, xml, flags)
  3681. if ret is None:raise libvirtError('virInterfaceDefineXML() failed', conn=self)
  3682. __tmp = virInterface(self, _obj=ret)
  3683. return __tmp
  3684.  
  3685. def interfaceLookupByMACString(self, macstr):
  3686. """Try to lookup an interface on the given hypervisor based on its MAC.
  3687.  
  3688. virInterfaceFree should be used to free the resources after the
  3689. interface object is no longer needed. """
  3690. ret = libvirtmod.virInterfaceLookupByMACString(self._o, macstr)
  3691. if ret is None:raise libvirtError('virInterfaceLookupByMACString() failed', conn=self)
  3692. __tmp = virInterface(self, _obj=ret)
  3693. return __tmp
  3694.  
  3695. def interfaceLookupByName(self, name):
  3696. """Try to lookup an interface on the given hypervisor based on its name.
  3697.  
  3698. virInterfaceFree should be used to free the resources after the
  3699. interface object is no longer needed. """
  3700. ret = libvirtmod.virInterfaceLookupByName(self._o, name)
  3701. if ret is None:raise libvirtError('virInterfaceLookupByName() failed', conn=self)
  3702. __tmp = virInterface(self, _obj=ret)
  3703. return __tmp
  3704.  
  3705. def isAlive(self):
  3706. """Determine if the connection to the hypervisor is still alive
  3707.  
  3708. A connection will be classed as alive if it is either local, or running
  3709. over a channel (TCP or UNIX socket) which is not closed. """
  3710. ret = libvirtmod.virConnectIsAlive(self._o)
  3711. if ret == -1: raise libvirtError ('virConnectIsAlive() failed', conn=self)
  3712. return ret
  3713.  
  3714. def isEncrypted(self):
  3715. """Determine if the connection to the hypervisor is encrypted """
  3716. ret = libvirtmod.virConnectIsEncrypted(self._o)
  3717. if ret == -1: raise libvirtError ('virConnectIsEncrypted() failed', conn=self)
  3718. return ret
  3719.  
  3720. def isSecure(self):
  3721. """Determine if the connection to the hypervisor is secure
  3722.  
  3723. A connection will be classed as secure if it is either
  3724. encrypted, or running over a channel which is not exposed
  3725. to eavesdropping (eg a UNIX domain socket, or pipe) """
  3726. ret = libvirtmod.virConnectIsSecure(self._o)
  3727. if ret == -1: raise libvirtError ('virConnectIsSecure() failed', conn=self)
  3728. return ret
  3729.  
  3730. #
  3731. # virConnect functions from module python
  3732. #
  3733.  
  3734. def listDefinedDomains(self):
  3735. """list the defined domains, stores the pointers to the names in @names """
  3736. ret = libvirtmod.virConnectListDefinedDomains(self._o)
  3737. if ret is None: raise libvirtError ('virConnectListDefinedDomains() failed', conn=self)
  3738. return ret
  3739.  
  3740. def listDefinedInterfaces(self):
  3741. """list the defined interfaces, stores the pointers to the names in @names """
  3742. ret = libvirtmod.virConnectListDefinedInterfaces(self._o)
  3743. if ret is None: raise libvirtError ('virConnectListDefinedInterfaces() failed', conn=self)
  3744. return ret
  3745.  
  3746. def listDefinedNetworks(self):
  3747. """list the defined networks, stores the pointers to the names in @names """
  3748. ret = libvirtmod.virConnectListDefinedNetworks(self._o)
  3749. if ret is None: raise libvirtError ('virConnectListDefinedNetworks() failed', conn=self)
  3750. return ret
  3751.  
  3752. def listDefinedStoragePools(self):
  3753. """list the defined storage pool, stores the pointers to the names in @names """
  3754. ret = libvirtmod.virConnectListDefinedStoragePools(self._o)
  3755. if ret is None: raise libvirtError ('virConnectListDefinedStoragePools() failed', conn=self)
  3756. return ret
  3757.  
  3758. def listDevices(self, cap, flags=0):
  3759. """list the node devices """
  3760. ret = libvirtmod.virNodeListDevices(self._o, cap, flags)
  3761. if ret is None: raise libvirtError ('virNodeListDevices() failed', conn=self)
  3762. return ret
  3763.  
  3764. def listDomainsID(self):
  3765. """Returns the list of the ID of the domains on the hypervisor """
  3766. ret = libvirtmod.virConnectListDomainsID(self._o)
  3767. if ret is None: raise libvirtError ('virConnectListDomainsID() failed', conn=self)
  3768. return ret
  3769.  
  3770. def listInterfaces(self):
  3771. """list the running interfaces, stores the pointers to the names in @names """
  3772. ret = libvirtmod.virConnectListInterfaces(self._o)
  3773. if ret is None: raise libvirtError ('virConnectListInterfaces() failed', conn=self)
  3774. return ret
  3775.  
  3776. #
  3777. # virConnect functions from module libvirt
  3778. #
  3779.  
  3780. def listNWFilters(self):
  3781. """List the defined network filters """
  3782. ret = libvirtmod.virConnectListNWFilters(self._o)
  3783. if ret is None: raise libvirtError ('virConnectListNWFilters() failed', conn=self)
  3784. return ret
  3785.  
  3786. #
  3787. # virConnect functions from module python
  3788. #
  3789.  
  3790. def listNetworks(self):
  3791. """list the networks, stores the pointers to the names in @names """
  3792. ret = libvirtmod.virConnectListNetworks(self._o)
  3793. if ret is None: raise libvirtError ('virConnectListNetworks() failed', conn=self)
  3794. return ret
  3795.  
  3796. #
  3797. # virConnect functions from module libvirt
  3798. #
  3799.  
  3800. def listSecrets(self):
  3801. """List the defined secret IDs """
  3802. ret = libvirtmod.virConnectListSecrets(self._o)
  3803. if ret is None: raise libvirtError ('virConnectListSecrets() failed', conn=self)
  3804. return ret
  3805.  
  3806. #
  3807. # virConnect functions from module python
  3808. #
  3809.  
  3810. def listStoragePools(self):
  3811. """list the storage pools, stores the pointers to the names in @names """
  3812. ret = libvirtmod.virConnectListStoragePools(self._o)
  3813. if ret is None: raise libvirtError ('virConnectListStoragePools() failed', conn=self)
  3814. return ret
  3815.  
  3816. #
  3817. # virConnect functions from module libvirt
  3818. #
  3819.  
  3820. def lookupByID(self, id):
  3821. """Try to find a domain based on the hypervisor ID number
  3822. Note that this won't work for inactive domains which have an ID of -1,
  3823. in that case a lookup based on the Name or UUId need to be done instead.
  3824.  
  3825. virDomainFree should be used to free the resources after the
  3826. domain object is no longer needed. """
  3827. ret = libvirtmod.virDomainLookupByID(self._o, id)
  3828. if ret is None:raise libvirtError('virDomainLookupByID() failed', conn=self)
  3829. __tmp = virDomain(self,_obj=ret)
  3830. return __tmp
  3831.  
  3832. def lookupByName(self, name):
  3833. """Try to lookup a domain on the given hypervisor based on its name.
  3834.  
  3835. virDomainFree should be used to free the resources after the
  3836. domain object is no longer needed. """
  3837. ret = libvirtmod.virDomainLookupByName(self._o, name)
  3838. if ret is None:raise libvirtError('virDomainLookupByName() failed', conn=self)
  3839. __tmp = virDomain(self,_obj=ret)
  3840. return __tmp
  3841.  
  3842. #
  3843. # virConnect functions from module python
  3844. #
  3845.  
  3846. def lookupByUUID(self, uuid):
  3847. """Try to lookup a domain on the given hypervisor based on its UUID. """
  3848. ret = libvirtmod.virDomainLookupByUUID(self._o, uuid)
  3849. if ret is None:raise libvirtError('virDomainLookupByUUID() failed', conn=self)
  3850. __tmp = virDomain(self,_obj=ret)
  3851. return __tmp
  3852.  
  3853. #
  3854. # virConnect functions from module libvirt
  3855. #
  3856.  
  3857. def lookupByUUIDString(self, uuidstr):
  3858. """Try to lookup a domain on the given hypervisor based on its UUID.
  3859.  
  3860. virDomainFree should be used to free the resources after the
  3861. domain object is no longer needed. """
  3862. ret = libvirtmod.virDomainLookupByUUIDString(self._o, uuidstr)
  3863. if ret is None:raise libvirtError('virDomainLookupByUUIDString() failed', conn=self)
  3864. __tmp = virDomain(self,_obj=ret)
  3865. return __tmp
  3866.  
  3867. def networkCreateXML(self, xmlDesc):
  3868. """Create and start a new virtual network, based on an XML description
  3869. similar to the one returned by virNetworkGetXMLDesc()
  3870.  
  3871. virNetworkFree should be used to free the resources after the
  3872. network object is no longer needed. """
  3873. ret = libvirtmod.virNetworkCreateXML(self._o, xmlDesc)
  3874. if ret is None:raise libvirtError('virNetworkCreateXML() failed', conn=self)
  3875. __tmp = virNetwork(self, _obj=ret)
  3876. return __tmp
  3877.  
  3878. def networkDefineXML(self, xml):
  3879. """Define a network, but does not create it
  3880.  
  3881. virNetworkFree should be used to free the resources after the
  3882. network object is no longer needed. """
  3883. ret = libvirtmod.virNetworkDefineXML(self._o, xml)
  3884. if ret is None:raise libvirtError('virNetworkDefineXML() failed', conn=self)
  3885. __tmp = virNetwork(self, _obj=ret)
  3886. return __tmp
  3887.  
  3888. def networkLookupByName(self, name):
  3889. """Try to lookup a network on the given hypervisor based on its name.
  3890.  
  3891. virNetworkFree should be used to free the resources after the
  3892. network object is no longer needed. """
  3893. ret = libvirtmod.virNetworkLookupByName(self._o, name)
  3894. if ret is None:raise libvirtError('virNetworkLookupByName() failed', conn=self)
  3895. __tmp = virNetwork(self, _obj=ret)
  3896. return __tmp
  3897.  
  3898. #
  3899. # virConnect functions from module python
  3900. #
  3901.  
  3902. def networkLookupByUUID(self, uuid):
  3903. """Try to lookup a network on the given hypervisor based on its UUID. """
  3904. ret = libvirtmod.virNetworkLookupByUUID(self._o, uuid)
  3905. if ret is None:raise libvirtError('virNetworkLookupByUUID() failed', conn=self)
  3906. __tmp = virNetwork(self, _obj=ret)
  3907. return __tmp
  3908.  
  3909. #
  3910. # virConnect functions from module libvirt
  3911. #
  3912.  
  3913. def networkLookupByUUIDString(self, uuidstr):
  3914. """Try to lookup a network on the given hypervisor based on its UUID. """
  3915. ret = libvirtmod.virNetworkLookupByUUIDString(self._o, uuidstr)
  3916. if ret is None:raise libvirtError('virNetworkLookupByUUIDString() failed', conn=self)
  3917. __tmp = virNetwork(self, _obj=ret)
  3918. return __tmp
  3919.  
  3920. def newStream(self, flags=0):
  3921. """Creates a new stream object which can be used to perform
  3922. streamed I/O with other public API function.
  3923.  
  3924. When no longer needed, a stream object must be released
  3925. with virStreamFree. If a data stream has been used,
  3926. then the application must call virStreamFinish or
  3927. virStreamAbort before free'ing to, in order to notify
  3928. the driver of termination.
  3929.  
  3930. If a non-blocking data stream is required passed
  3931. VIR_STREAM_NONBLOCK for flags, otherwise pass 0. """
  3932. ret = libvirtmod.virStreamNew(self._o, flags)
  3933. if ret is None:raise libvirtError('virStreamNew() failed', conn=self)
  3934. __tmp = virStream(self, _obj=ret)
  3935. return __tmp
  3936.  
  3937. def nodeDeviceCreateXML(self, xmlDesc, flags=0):
  3938. """Create a new device on the VM host machine, for example, virtual
  3939. HBAs created using vport_create.
  3940.  
  3941. virNodeDeviceFree should be used to free the resources after the
  3942. node device object is no longer needed. """
  3943. ret = libvirtmod.virNodeDeviceCreateXML(self._o, xmlDesc, flags)
  3944. if ret is None:raise libvirtError('virNodeDeviceCreateXML() failed', conn=self)
  3945. __tmp = virNodeDevice(self, _obj=ret)
  3946. return __tmp
  3947.  
  3948. def nodeDeviceLookupByName(self, name):
  3949. """Lookup a node device by its name.
  3950.  
  3951. virNodeDeviceFree should be used to free the resources after the
  3952. node device object is no longer needed. """
  3953. ret = libvirtmod.virNodeDeviceLookupByName(self._o, name)
  3954. if ret is None:raise libvirtError('virNodeDeviceLookupByName() failed', conn=self)
  3955. __tmp = virNodeDevice(self, _obj=ret)
  3956. return __tmp
  3957.  
  3958. def nodeDeviceLookupSCSIHostByWWN(self, wwnn, wwpn, flags=0):
  3959. """Lookup SCSI Host which is capable with 'fc_host' by its WWNN and WWPN.
  3960.  
  3961. virNodeDeviceFree should be used to free the resources after the
  3962. node device object is no longer needed. """
  3963. ret = libvirtmod.virNodeDeviceLookupSCSIHostByWWN(self._o, wwnn, wwpn, flags)
  3964. if ret is None:raise libvirtError('virNodeDeviceLookupSCSIHostByWWN() failed', conn=self)
  3965. __tmp = virNodeDevice(self, _obj=ret)
  3966. return __tmp
  3967.  
  3968. def numOfDefinedDomains(self):
  3969. """Provides the number of defined but inactive domains. """
  3970. ret = libvirtmod.virConnectNumOfDefinedDomains(self._o)
  3971. if ret == -1: raise libvirtError ('virConnectNumOfDefinedDomains() failed', conn=self)
  3972. return ret
  3973.  
  3974. def numOfDefinedInterfaces(self):
  3975. """Provides the number of defined (inactive) interfaces on the physical host. """
  3976. ret = libvirtmod.virConnectNumOfDefinedInterfaces(self._o)
  3977. if ret == -1: raise libvirtError ('virConnectNumOfDefinedInterfaces() failed', conn=self)
  3978. return ret
  3979.  
  3980. def numOfDefinedNetworks(self):
  3981. """Provides the number of inactive networks. """
  3982. ret = libvirtmod.virConnectNumOfDefinedNetworks(self._o)
  3983. if ret == -1: raise libvirtError ('virConnectNumOfDefinedNetworks() failed', conn=self)
  3984. return ret
  3985.  
  3986. def numOfDefinedStoragePools(self):
  3987. """Provides the number of inactive storage pools """
  3988. ret = libvirtmod.virConnectNumOfDefinedStoragePools(self._o)
  3989. if ret == -1: raise libvirtError ('virConnectNumOfDefinedStoragePools() failed', conn=self)
  3990. return ret
  3991.  
  3992. def numOfDevices(self, cap, flags=0):
  3993. """Provides the number of node devices.
  3994.  
  3995. If the optional 'cap' argument is non-None, then the count
  3996. will be restricted to devices with the specified capability """
  3997. ret = libvirtmod.virNodeNumOfDevices(self._o, cap, flags)
  3998. if ret == -1: raise libvirtError ('virNodeNumOfDevices() failed', conn=self)
  3999. return ret
  4000.  
  4001. def numOfDomains(self):
  4002. """Provides the number of active domains. """
  4003. ret = libvirtmod.virConnectNumOfDomains(self._o)
  4004. if ret == -1: raise libvirtError ('virConnectNumOfDomains() failed', conn=self)
  4005. return ret
  4006.  
  4007. def numOfInterfaces(self):
  4008. """Provides the number of active interfaces on the physical host. """
  4009. ret = libvirtmod.virConnectNumOfInterfaces(self._o)
  4010. if ret == -1: raise libvirtError ('virConnectNumOfInterfaces() failed', conn=self)
  4011. return ret
  4012.  
  4013. def numOfNWFilters(self):
  4014. """Provides the number of nwfilters. """
  4015. ret = libvirtmod.virConnectNumOfNWFilters(self._o)
  4016. if ret == -1: raise libvirtError ('virConnectNumOfNWFilters() failed', conn=self)
  4017. return ret
  4018.  
  4019. def numOfNetworks(self):
  4020. """Provides the number of active networks. """
  4021. ret = libvirtmod.virConnectNumOfNetworks(self._o)
  4022. if ret == -1: raise libvirtError ('virConnectNumOfNetworks() failed', conn=self)
  4023. return ret
  4024.  
  4025. def numOfSecrets(self):
  4026. """Fetch number of currently defined secrets. """
  4027. ret = libvirtmod.virConnectNumOfSecrets(self._o)
  4028. if ret == -1: raise libvirtError ('virConnectNumOfSecrets() failed', conn=self)
  4029. return ret
  4030.  
  4031. def numOfStoragePools(self):
  4032. """Provides the number of active storage pools """
  4033. ret = libvirtmod.virConnectNumOfStoragePools(self._o)
  4034. if ret == -1: raise libvirtError ('virConnectNumOfStoragePools() failed', conn=self)
  4035. return ret
  4036.  
  4037. def nwfilterDefineXML(self, xmlDesc):
  4038. """Define a new network filter, based on an XML description
  4039. similar to the one returned by virNWFilterGetXMLDesc()
  4040.  
  4041. virNWFilterFree should be used to free the resources after the
  4042. nwfilter object is no longer needed. """
  4043. ret = libvirtmod.virNWFilterDefineXML(self._o, xmlDesc)
  4044. if ret is None:raise libvirtError('virNWFilterDefineXML() failed', conn=self)
  4045. __tmp = virNWFilter(self, _obj=ret)
  4046. return __tmp
  4047.  
  4048. def nwfilterLookupByName(self, name):
  4049. """Try to lookup a network filter on the given hypervisor based on its name.
  4050.  
  4051. virNWFilterFree should be used to free the resources after the
  4052. nwfilter object is no longer needed. """
  4053. ret = libvirtmod.virNWFilterLookupByName(self._o, name)
  4054. if ret is None:raise libvirtError('virNWFilterLookupByName() failed', conn=self)
  4055. __tmp = virNWFilter(self, _obj=ret)
  4056. return __tmp
  4057.  
  4058. #
  4059. # virConnect functions from module python
  4060. #
  4061.  
  4062. def nwfilterLookupByUUID(self, uuid):
  4063. """Try to lookup a network filter on the given hypervisor based on its UUID. """
  4064. ret = libvirtmod.virNWFilterLookupByUUID(self._o, uuid)
  4065. if ret is None:raise libvirtError('virNWFilterLookupByUUID() failed', conn=self)
  4066. __tmp = virNWFilter(self, _obj=ret)
  4067. return __tmp
  4068.  
  4069. #
  4070. # virConnect functions from module libvirt
  4071. #
  4072.  
  4073. def nwfilterLookupByUUIDString(self, uuidstr):
  4074. """Try to lookup an nwfilter on the given hypervisor based on its UUID.
  4075.  
  4076. virNWFilterFree should be used to free the resources after the
  4077. nwfilter object is no longer needed. """
  4078. ret = libvirtmod.virNWFilterLookupByUUIDString(self._o, uuidstr)
  4079. if ret is None:raise libvirtError('virNWFilterLookupByUUIDString() failed', conn=self)
  4080. __tmp = virNWFilter(self, _obj=ret)
  4081. return __tmp
  4082.  
  4083. def restore(self, frm):
  4084. """This method will restore a domain saved to disk by virDomainSave().
  4085.  
  4086. See virDomainRestoreFlags() for more control. """
  4087. ret = libvirtmod.virDomainRestore(self._o, frm)
  4088. if ret == -1: raise libvirtError ('virDomainRestore() failed', conn=self)
  4089. return ret
  4090.  
  4091. def restoreFlags(self, frm, dxml=None, flags=0):
  4092. """This method will restore a domain saved to disk by virDomainSave().
  4093.  
  4094. If the hypervisor supports it, @dxml can be used to alter
  4095. host-specific portions of the domain XML that will be used when
  4096. restoring an image. For example, it is possible to alter the
  4097. backing filename that is associated with a disk device, in order to
  4098. prepare for file renaming done as part of backing up the disk
  4099. device while the domain is stopped.
  4100.  
  4101. If @flags includes VIR_DOMAIN_SAVE_BYPASS_CACHE, then libvirt will
  4102. attempt to bypass the file system cache while restoring the file, or
  4103. fail if it cannot do so for the given system; this can allow less
  4104. pressure on file system cache, but also risks slowing restores from NFS.
  4105.  
  4106. Normally, the saved state file will remember whether the domain was
  4107. running or paused, and restore defaults to the same state.
  4108. Specifying VIR_DOMAIN_SAVE_RUNNING or VIR_DOMAIN_SAVE_PAUSED in
  4109. @flags will override the default read from the file. These two
  4110. flags are mutually exclusive. """
  4111. ret = libvirtmod.virDomainRestoreFlags(self._o, frm, dxml, flags)
  4112. if ret == -1: raise libvirtError ('virDomainRestoreFlags() failed', conn=self)
  4113. return ret
  4114.  
  4115. def saveImageDefineXML(self, file, dxml, flags=0):
  4116. """This updates the definition of a domain stored in a saved state
  4117. file. @file must be a file created previously by virDomainSave()
  4118. or virDomainSaveFlags().
  4119.  
  4120. @dxml can be used to alter host-specific portions of the domain XML
  4121. that will be used when restoring an image. For example, it is
  4122. possible to alter the backing filename that is associated with a
  4123. disk device, to match renaming done as part of backing up the disk
  4124. device while the domain is stopped.
  4125.  
  4126. Normally, the saved state file will remember whether the domain was
  4127. running or paused, and restore defaults to the same state.
  4128. Specifying VIR_DOMAIN_SAVE_RUNNING or VIR_DOMAIN_SAVE_PAUSED in
  4129. @flags will override the default saved into the file; omitting both
  4130. leaves the file's default unchanged. These two flags are mutually
  4131. exclusive. """
  4132. ret = libvirtmod.virDomainSaveImageDefineXML(self._o, file, dxml, flags)
  4133. if ret == -1: raise libvirtError ('virDomainSaveImageDefineXML() failed', conn=self)
  4134. return ret
  4135.  
  4136. def saveImageGetXMLDesc(self, file, flags=0):
  4137. """This method will extract the XML describing the domain at the time
  4138. a saved state file was created. @file must be a file created
  4139. previously by virDomainSave() or virDomainSaveFlags().
  4140.  
  4141. No security-sensitive data will be included unless @flags contains
  4142. VIR_DOMAIN_XML_SECURE; this flag is rejected on read-only
  4143. connections. For this API, @flags should not contain either
  4144. VIR_DOMAIN_XML_INACTIVE or VIR_DOMAIN_XML_UPDATE_CPU. """
  4145. ret = libvirtmod.virDomainSaveImageGetXMLDesc(self._o, file, flags)
  4146. if ret is None: raise libvirtError ('virDomainSaveImageGetXMLDesc() failed', conn=self)
  4147. return ret
  4148.  
  4149. def secretDefineXML(self, xml, flags=0):
  4150. """If XML specifies a UUID, locates the specified secret and replaces all
  4151. attributes of the secret specified by UUID by attributes specified in xml
  4152. (any attributes not specified in xml are discarded).
  4153.  
  4154. Otherwise, creates a new secret with an automatically chosen UUID, and
  4155. initializes its attributes from xml.
  4156.  
  4157. virSecretFree should be used to free the resources after the
  4158. secret object is no longer needed. """
  4159. ret = libvirtmod.virSecretDefineXML(self._o, xml, flags)
  4160. if ret is None:raise libvirtError('virSecretDefineXML() failed', conn=self)
  4161. __tmp = virSecret(self, _obj=ret)
  4162. return __tmp
  4163.  
  4164. #
  4165. # virConnect functions from module python
  4166. #
  4167.  
  4168. def secretLookupByUUID(self, uuid):
  4169. """Try to lookup a secret on the given hypervisor based on its UUID. """
  4170. ret = libvirtmod.virSecretLookupByUUID(self._o, uuid)
  4171. if ret is None:raise libvirtError('virSecretLookupByUUID() failed', conn=self)
  4172. __tmp = virSecret(self, _obj=ret)
  4173. return __tmp
  4174.  
  4175. #
  4176. # virConnect functions from module libvirt
  4177. #
  4178.  
  4179. def secretLookupByUUIDString(self, uuidstr):
  4180. """Try to lookup a secret on the given hypervisor based on its UUID.
  4181. Uses the printable string value to describe the UUID
  4182.  
  4183. virSecretFree should be used to free the resources after the
  4184. secret object is no longer needed. """
  4185. ret = libvirtmod.virSecretLookupByUUIDString(self._o, uuidstr)
  4186. if ret is None:raise libvirtError('virSecretLookupByUUIDString() failed', conn=self)
  4187. __tmp = virSecret(self, _obj=ret)
  4188. return __tmp
  4189.  
  4190. def secretLookupByUsage(self, usageType, usageID):
  4191. """Try to lookup a secret on the given hypervisor based on its usage
  4192. The usageID is unique within the set of secrets sharing the
  4193. same usageType value.
  4194.  
  4195. virSecretFree should be used to free the resources after the
  4196. secret object is no longer needed. """
  4197. ret = libvirtmod.virSecretLookupByUsage(self._o, usageType, usageID)
  4198. if ret is None:raise libvirtError('virSecretLookupByUsage() failed', conn=self)
  4199. __tmp = virSecret(self, _obj=ret)
  4200. return __tmp
  4201.  
  4202. def setKeepAlive(self, interval, count):
  4203. """Start sending keepalive messages after @interval seconds of inactivity and
  4204. consider the connection to be broken when no response is received after
  4205. @count keepalive messages sent in a row. In other words, sending count + 1
  4206. keepalive message results in closing the connection. When @interval is
  4207. <= 0, no keepalive messages will be sent. When @count is 0, the connection
  4208. will be automatically closed after @interval seconds of inactivity without
  4209. sending any keepalive messages.
  4210.  
  4211. Note: The client has to implement and run an event loop with
  4212. virEventRegisterImpl() or virEventRegisterDefaultImpl() to be able to
  4213. use keepalive messages. Failure to do so may result in connections
  4214. being closed unexpectedly.
  4215.  
  4216. Note: This API function controls only keepalive messages sent by the client.
  4217. If the server is configured to use keepalive you still need to run the event
  4218. loop to respond to them, even if you disable keepalives by this function. """
  4219. ret = libvirtmod.virConnectSetKeepAlive(self._o, interval, count)
  4220. if ret == -1: raise libvirtError ('virConnectSetKeepAlive() failed', conn=self)
  4221. return ret
  4222.  
  4223. #
  4224. # virConnect functions from module python
  4225. #
  4226.  
  4227. def setMemoryParameters(self, params, flags=0):
  4228. """Change the node memory tunables """
  4229. ret = libvirtmod.virNodeSetMemoryParameters(self._o, params, flags)
  4230. if ret == -1: raise libvirtError ('virNodeSetMemoryParameters() failed', conn=self)
  4231. return ret
  4232.  
  4233. #
  4234. # virConnect functions from module libvirt
  4235. #
  4236.  
  4237. def storagePoolCreateXML(self, xmlDesc, flags=0):
  4238. """Create a new storage based on its XML description. The
  4239. pool is not persistent, so its definition will disappear
  4240. when it is destroyed, or if the host is restarted
  4241.  
  4242. virStoragePoolFree should be used to free the resources after the
  4243. storage pool object is no longer needed. """
  4244. ret = libvirtmod.virStoragePoolCreateXML(self._o, xmlDesc, flags)
  4245. if ret is None:raise libvirtError('virStoragePoolCreateXML() failed', conn=self)
  4246. __tmp = virStoragePool(self, _obj=ret)
  4247. return __tmp
  4248.  
  4249. def storagePoolDefineXML(self, xml, flags=0):
  4250. """Define a new inactive storage pool based on its XML description. The
  4251. pool is persistent, until explicitly undefined.
  4252.  
  4253. virStoragePoolFree should be used to free the resources after the
  4254. storage pool object is no longer needed. """
  4255. ret = libvirtmod.virStoragePoolDefineXML(self._o, xml, flags)
  4256. if ret is None:raise libvirtError('virStoragePoolDefineXML() failed', conn=self)
  4257. __tmp = virStoragePool(self, _obj=ret)
  4258. return __tmp
  4259.  
  4260. def storagePoolLookupByName(self, name):
  4261. """Fetch a storage pool based on its unique name
  4262.  
  4263. virStoragePoolFree should be used to free the resources after the
  4264. storage pool object is no longer needed. """
  4265. ret = libvirtmod.virStoragePoolLookupByName(self._o, name)
  4266. if ret is None:raise libvirtError('virStoragePoolLookupByName() failed', conn=self)
  4267. __tmp = virStoragePool(self, _obj=ret)
  4268. return __tmp
  4269.  
  4270. def storagePoolLookupByUUID(self, uuid):
  4271. """Fetch a storage pool based on its globally unique id
  4272.  
  4273. virStoragePoolFree should be used to free the resources after the
  4274. storage pool object is no longer needed. """
  4275. ret = libvirtmod.virStoragePoolLookupByUUID(self._o, uuid)
  4276. if ret is None:raise libvirtError('virStoragePoolLookupByUUID() failed', conn=self)
  4277. __tmp = virStoragePool(self, _obj=ret)
  4278. return __tmp
  4279.  
  4280. def storagePoolLookupByUUIDString(self, uuidstr):
  4281. """Fetch a storage pool based on its globally unique id
  4282.  
  4283. virStoragePoolFree should be used to free the resources after the
  4284. storage pool object is no longer needed. """
  4285. ret = libvirtmod.virStoragePoolLookupByUUIDString(self._o, uuidstr)
  4286. if ret is None:raise libvirtError('virStoragePoolLookupByUUIDString() failed', conn=self)
  4287. __tmp = virStoragePool(self, _obj=ret)
  4288. return __tmp
  4289.  
  4290. def storageVolLookupByKey(self, key):
  4291. """Fetch a pointer to a storage volume based on its
  4292. globally unique key
  4293.  
  4294. virStorageVolFree should be used to free the resources after the
  4295. storage volume object is no longer needed. """
  4296. ret = libvirtmod.virStorageVolLookupByKey(self._o, key)
  4297. if ret is None:raise libvirtError('virStorageVolLookupByKey() failed', conn=self)
  4298. __tmp = virStorageVol(self, _obj=ret)
  4299. return __tmp
  4300.  
  4301. def storageVolLookupByPath(self, path):
  4302. """Fetch a pointer to a storage volume based on its
  4303. locally (host) unique path
  4304.  
  4305. virStorageVolFree should be used to free the resources after the
  4306. storage volume object is no longer needed. """
  4307. ret = libvirtmod.virStorageVolLookupByPath(self._o, path)
  4308. if ret is None:raise libvirtError('virStorageVolLookupByPath() failed', conn=self)
  4309. __tmp = virStorageVol(self, _obj=ret)
  4310. return __tmp
  4311.  
  4312. def suspendForDuration(self, target, duration, flags=0):
  4313. """Attempt to suspend the node (host machine) for the given duration of
  4314. time in the specified state (Suspend-to-RAM, Suspend-to-Disk or
  4315. Hybrid-Suspend). Schedule the node's Real-Time-Clock interrupt to
  4316. resume the node after the duration is complete. """
  4317. ret = libvirtmod.virNodeSuspendForDuration(self._o, target, duration, flags)
  4318. if ret == -1: raise libvirtError ('virNodeSuspendForDuration() failed', conn=self)
  4319. return ret
  4320.  
  4321. #
  4322. # virConnect functions from module virterror
  4323. #
  4324.  
  4325. def virConnGetLastError(self):
  4326. """Provide a pointer to the last error caught on that connection
  4327.  
  4328. This method is not protected against access from multiple
  4329. threads. In a multi-threaded application, always use the
  4330. global virGetLastError() API which is backed by thread
  4331. local storage.
  4332.  
  4333. If the connection object was discovered to be invalid by
  4334. an API call, then the error will be reported against the
  4335. global error object.
  4336.  
  4337. Since 0.6.0, all errors reported in the per-connection object
  4338. are also duplicated in the global error object. As such an
  4339. application can always use virGetLastError(). This method
  4340. remains for backwards compatibility. """
  4341. ret = libvirtmod.virConnGetLastError(self._o)
  4342. return ret
  4343.  
  4344. def virConnResetLastError(self):
  4345. """The error object is kept in thread local storage, so separate
  4346. threads can safely access this concurrently.
  4347.  
  4348. Reset the last error caught on that connection """
  4349. libvirtmod.virConnResetLastError(self._o)
  4350.  
  4351. #
  4352. # virConnect methods from virConnect.py (hand coded)
  4353. #
  4354. def __del__(self):
  4355. try:
  4356. for cb,opaque in self.domainEventCallbacks.items():
  4357. del self.domainEventCallbacks[cb]
  4358. del self.domainEventCallbacks
  4359. libvirtmod.virConnectDomainEventDeregister(self._o, self)
  4360. except AttributeError:
  4361. pass
  4362.  
  4363. if self._o is not None:
  4364. libvirtmod.virConnectClose(self._o)
  4365. self._o = None
  4366.  
  4367. def domainEventDeregister(self, cb):
  4368. """Removes a Domain Event Callback. De-registering for a
  4369. domain callback will disable delivery of this event type """
  4370. try:
  4371. del self.domainEventCallbacks[cb]
  4372. if len(self.domainEventCallbacks) == 0:
  4373. del self.domainEventCallbacks
  4374. ret = libvirtmod.virConnectDomainEventDeregister(self._o, self)
  4375. if ret == -1: raise libvirtError ('virConnectDomainEventDeregister() failed', conn=self)
  4376. except AttributeError:
  4377. pass
  4378.  
  4379. def domainEventRegister(self, cb, opaque):
  4380. """Adds a Domain Event Callback. Registering for a domain
  4381. callback will enable delivery of the events """
  4382. try:
  4383. self.domainEventCallbacks[cb] = opaque
  4384. except AttributeError:
  4385. self.domainEventCallbacks = {cb:opaque}
  4386. ret = libvirtmod.virConnectDomainEventRegister(self._o, self)
  4387. if ret == -1: raise libvirtError ('virConnectDomainEventRegister() failed', conn=self)
  4388.  
  4389. def _dispatchDomainEventCallbacks(self, dom, event, detail):
  4390. """Dispatches events to python user domain event callbacks
  4391. """
  4392. try:
  4393. for cb,opaque in self.domainEventCallbacks.items():
  4394. cb(self, virDomain(self, _obj=dom), event, detail, opaque)
  4395. return 0
  4396. except AttributeError:
  4397. pass
  4398.  
  4399. def _dispatchDomainEventLifecycleCallback(self, dom, event, detail, cbData):
  4400. """Dispatches events to python user domain lifecycle event callbacks
  4401. """
  4402. cb = cbData["cb"]
  4403. opaque = cbData["opaque"]
  4404.  
  4405. cb(self, virDomain(self, _obj=dom), event, detail, opaque)
  4406. return 0
  4407.  
  4408. def _dispatchDomainEventGenericCallback(self, dom, cbData):
  4409. """Dispatches events to python user domain generic event callbacks
  4410. """
  4411. cb = cbData["cb"]
  4412. opaque = cbData["opaque"]
  4413.  
  4414. cb(self, virDomain(self, _obj=dom), opaque)
  4415. return 0
  4416.  
  4417. def _dispatchDomainEventRTCChangeCallback(self, dom, offset, cbData):
  4418. """Dispatches events to python user domain RTC change event callbacks
  4419. """
  4420. cb = cbData["cb"]
  4421. opaque = cbData["opaque"]
  4422.  
  4423. cb(self, virDomain(self, _obj=dom), offset ,opaque)
  4424. return 0
  4425.  
  4426. def _dispatchDomainEventWatchdogCallback(self, dom, action, cbData):
  4427. """Dispatches events to python user domain watchdog event callbacks
  4428. """
  4429. cb = cbData["cb"]
  4430. opaque = cbData["opaque"]
  4431.  
  4432. cb(self, virDomain(self, _obj=dom), action, opaque)
  4433. return 0
  4434.  
  4435. def _dispatchDomainEventIOErrorCallback(self, dom, srcPath, devAlias,
  4436. action, cbData):
  4437. """Dispatches events to python user domain IO error event callbacks
  4438. """
  4439. cb = cbData["cb"]
  4440. opaque = cbData["opaque"]
  4441.  
  4442. cb(self, virDomain(self, _obj=dom), srcPath, devAlias, action, opaque)
  4443. return 0
  4444.  
  4445. def _dispatchDomainEventIOErrorReasonCallback(self, dom, srcPath,
  4446. devAlias, action, reason,
  4447. cbData):
  4448. """Dispatches events to python user domain IO error event callbacks
  4449. """
  4450. cb = cbData["cb"]
  4451. opaque = cbData["opaque"]
  4452.  
  4453. cb(self, virDomain(self, _obj=dom), srcPath, devAlias, action,
  4454. reason, opaque)
  4455. return 0
  4456.  
  4457. def _dispatchDomainEventGraphicsCallback(self, dom, phase, localAddr,
  4458. remoteAddr, authScheme, subject,
  4459. cbData):
  4460. """Dispatches events to python user domain graphics event callbacks
  4461. """
  4462. cb = cbData["cb"]
  4463. opaque = cbData["opaque"]
  4464.  
  4465. cb(self, virDomain(self, _obj=dom), phase, localAddr, remoteAddr,
  4466. authScheme, subject, opaque)
  4467. return 0
  4468.  
  4469. def _dispatchDomainEventBlockJobCallback(self, dom, disk, type, status, cbData):
  4470. """Dispatches events to python user domain blockJob/blockJob2 event callbacks
  4471. """
  4472. try:
  4473. cb = cbData["cb"]
  4474. opaque = cbData["opaque"]
  4475.  
  4476. cb(self, virDomain(self, _obj=dom), disk, type, status, opaque)
  4477. return 0
  4478. except AttributeError:
  4479. pass
  4480.  
  4481. def _dispatchDomainEventDiskChangeCallback(self, dom, oldSrcPath, newSrcPath, devAlias, reason, cbData):
  4482. """Dispatches event to python user domain diskChange event callbacks
  4483. """
  4484. cb = cbData["cb"]
  4485. opaque = cbData["opaque"]
  4486.  
  4487. cb(self, virDomain(self, _obj=dom), oldSrcPath, newSrcPath, devAlias, reason, opaque)
  4488. return 0
  4489.  
  4490. def _dispatchDomainEventTrayChangeCallback(self, dom, devAlias, reason, cbData):
  4491. """Dispatches event to python user domain trayChange event callbacks
  4492. """
  4493. cb = cbData["cb"]
  4494. opaque = cbData["opaque"]
  4495.  
  4496. cb(self, virDomain(self, _obj=dom), devAlias, reason, opaque)
  4497. return 0
  4498.  
  4499. def _dispatchDomainEventPMWakeupCallback(self, dom, reason, cbData):
  4500. """Dispatches event to python user domain pmwakeup event callbacks
  4501. """
  4502. cb = cbData["cb"]
  4503. opaque = cbData["opaque"]
  4504.  
  4505. cb(self, virDomain(self, _obj=dom), reason, opaque)
  4506. return 0
  4507.  
  4508. def _dispatchDomainEventPMSuspendCallback(self, dom, reason, cbData):
  4509. """Dispatches event to python user domain pmsuspend event callbacks
  4510. """
  4511. cb = cbData["cb"]
  4512. opaque = cbData["opaque"]
  4513.  
  4514. cb(self, virDomain(self, _obj=dom), reason, opaque)
  4515. return 0
  4516.  
  4517. def _dispatchDomainEventBalloonChangeCallback(self, dom, actual, cbData):
  4518. """Dispatches events to python user domain balloon change event callbacks
  4519. """
  4520. cb = cbData["cb"]
  4521. opaque = cbData["opaque"]
  4522.  
  4523. cb(self, virDomain(self, _obj=dom), actual, opaque)
  4524. return 0
  4525.  
  4526. def _dispatchDomainEventPMSuspendDiskCallback(self, dom, reason, cbData):
  4527. """Dispatches event to python user domain pmsuspend-disk event callbacks
  4528. """
  4529. cb = cbData["cb"]
  4530. opaque = cbData["opaque"]
  4531.  
  4532. cb(self, virDomain(self, _obj=dom), reason, opaque)
  4533. return 0
  4534.  
  4535. def _dispatchDomainEventDeviceRemovedCallback(self, dom, devAlias, cbData):
  4536. """Dispatches event to python user domain device removed event callbacks
  4537. """
  4538. cb = cbData["cb"]
  4539. opaque = cbData["opaque"]
  4540.  
  4541. cb(self, virDomain(self, _obj=dom), devAlias, opaque)
  4542. return 0
  4543.  
  4544. def _dispatchDomainEventTunableCallback(self, dom, params, cbData):
  4545. """Dispatches event to python user domain tunable event callbacks
  4546. """
  4547. cb = cbData["cb"]
  4548. opaque = cbData["opaque"]
  4549.  
  4550. cb(self, virDomain(self, _obj=dom), params, opaque)
  4551. return 0
  4552.  
  4553. def _dispatchDomainEventAgentLifecycleCallback(self, dom, state, reason, cbData):
  4554. """Dispatches event to python user domain agent lifecycle event callback
  4555. """
  4556.  
  4557. cb = cbData["cb"]
  4558. opaque = cbData["opaque"]
  4559.  
  4560. cb(self, virDomain(self, _obj=dom), state, reason, opaque)
  4561. return 0
  4562.  
  4563. def domainEventDeregisterAny(self, callbackID):
  4564. """Removes a Domain Event Callback. De-registering for a
  4565. domain callback will disable delivery of this event type """
  4566. try:
  4567. ret = libvirtmod.virConnectDomainEventDeregisterAny(self._o, callbackID)
  4568. if ret == -1: raise libvirtError ('virConnectDomainEventDeregisterAny() failed', conn=self)
  4569. del self.domainEventCallbackID[callbackID]
  4570. except AttributeError:
  4571. pass
  4572.  
  4573. def _dispatchNetworkEventLifecycleCallback(self, net, event, detail, cbData):
  4574. """Dispatches events to python user network lifecycle event callbacks
  4575. """
  4576. cb = cbData["cb"]
  4577. opaque = cbData["opaque"]
  4578.  
  4579. cb(self, virNetwork(self, _obj=net), event, detail, opaque)
  4580. return 0
  4581.  
  4582. def networkEventDeregisterAny(self, callbackID):
  4583. """Removes a Network Event Callback. De-registering for a
  4584. network callback will disable delivery of this event type"""
  4585. try:
  4586. ret = libvirtmod.virConnectNetworkEventDeregisterAny(self._o, callbackID)
  4587. if ret == -1: raise libvirtError ('virConnectNetworkEventDeregisterAny() failed', conn=self)
  4588. del self.networkEventCallbackID[callbackID]
  4589. except AttributeError:
  4590. pass
  4591.  
  4592. def networkEventRegisterAny(self, net, eventID, cb, opaque):
  4593. """Adds a Network Event Callback. Registering for a network
  4594. callback will enable delivery of the events"""
  4595. if not hasattr(self, 'networkEventCallbackID'):
  4596. self.networkEventCallbackID = {}
  4597. cbData = { "cb": cb, "conn": self, "opaque": opaque }
  4598. if net is None:
  4599. ret = libvirtmod.virConnectNetworkEventRegisterAny(self._o, None, eventID, cbData)
  4600. else:
  4601. ret = libvirtmod.virConnectNetworkEventRegisterAny(self._o, net._o, eventID, cbData)
  4602. if ret == -1:
  4603. raise libvirtError ('virConnectNetworkEventRegisterAny() failed', conn=self)
  4604. self.networkEventCallbackID[ret] = opaque
  4605. return ret
  4606.  
  4607. def domainEventRegisterAny(self, dom, eventID, cb, opaque):
  4608. """Adds a Domain Event Callback. Registering for a domain
  4609. callback will enable delivery of the events """
  4610. if not hasattr(self, 'domainEventCallbackID'):
  4611. self.domainEventCallbackID = {}
  4612. cbData = { "cb": cb, "conn": self, "opaque": opaque }
  4613. if dom is None:
  4614. ret = libvirtmod.virConnectDomainEventRegisterAny(self._o, None, eventID, cbData)
  4615. else:
  4616. ret = libvirtmod.virConnectDomainEventRegisterAny(self._o, dom._o, eventID, cbData)
  4617. if ret == -1:
  4618. raise libvirtError ('virConnectDomainEventRegisterAny() failed', conn=self)
  4619. self.domainEventCallbackID[ret] = opaque
  4620. return ret
  4621.  
  4622. def listAllDomains(self, flags=0):
  4623. """List all domains and returns a list of domain objects"""
  4624. ret = libvirtmod.virConnectListAllDomains(self._o, flags)
  4625. if ret is None:
  4626. raise libvirtError("virConnectListAllDomains() failed", conn=self)
  4627.  
  4628. retlist = list()
  4629. for domptr in ret:
  4630. retlist.append(virDomain(self, _obj=domptr))
  4631.  
  4632. return retlist
  4633.  
  4634. def listAllStoragePools(self, flags=0):
  4635. """Returns a list of storage pool objects"""
  4636. ret = libvirtmod.virConnectListAllStoragePools(self._o, flags)
  4637. if ret is None:
  4638. raise libvirtError("virConnectListAllStoragePools() failed", conn=self)
  4639.  
  4640. retlist = list()
  4641. for poolptr in ret:
  4642. retlist.append(virStoragePool(self, _obj=poolptr))
  4643.  
  4644. return retlist
  4645.  
  4646. def listAllNetworks(self, flags=0):
  4647. """Returns a list of network objects"""
  4648. ret = libvirtmod.virConnectListAllNetworks(self._o, flags)
  4649. if ret is None:
  4650. raise libvirtError("virConnectListAllNetworks() failed", conn=self)
  4651.  
  4652. retlist = list()
  4653. for netptr in ret:
  4654. retlist.append(virNetwork(self, _obj=netptr))
  4655.  
  4656. return retlist
  4657.  
  4658. def listAllInterfaces(self, flags=0):
  4659. """Returns a list of interface objects"""
  4660. ret = libvirtmod.virConnectListAllInterfaces(self._o, flags)
  4661. if ret is None:
  4662. raise libvirtError("virConnectListAllInterfaces() failed", conn=self)
  4663.  
  4664. retlist = list()
  4665. for ifaceptr in ret:
  4666. retlist.append(virInterface(self, _obj=ifaceptr))
  4667.  
  4668. return retlist
  4669.  
  4670. def listAllDevices(self, flags=0):
  4671. """Returns a list of host node device objects"""
  4672. ret = libvirtmod.virConnectListAllNodeDevices(self._o, flags)
  4673. if ret is None:
  4674. raise libvirtError("virConnectListAllNodeDevices() failed", conn=self)
  4675.  
  4676. retlist = list()
  4677. for devptr in ret:
  4678. retlist.append(virNodeDevice(self, _obj=devptr))
  4679.  
  4680. return retlist
  4681.  
  4682. def listAllNWFilters(self, flags=0):
  4683. """Returns a list of network filter objects"""
  4684. ret = libvirtmod.virConnectListAllNWFilters(self._o, flags)
  4685. if ret is None:
  4686. raise libvirtError("virConnectListAllNWFilters() failed", conn=self)
  4687.  
  4688. retlist = list()
  4689. for filter_ptr in ret:
  4690. retlist.append(virNWFilter(self, _obj=filter_ptr))
  4691.  
  4692. return retlist
  4693.  
  4694. def listAllSecrets(self, flags=0):
  4695. """Returns a list of secret objects"""
  4696. ret = libvirtmod.virConnectListAllSecrets(self._o, flags)
  4697. if ret is None:
  4698. raise libvirtError("virConnectListAllSecrets() failed", conn=self)
  4699.  
  4700. retlist = list()
  4701. for secret_ptr in ret:
  4702. retlist.append(virSecret(self, _obj=secret_ptr))
  4703.  
  4704. return retlist
  4705.  
  4706. def _dispatchCloseCallback(self, reason, cbData):
  4707. """Dispatches events to python user close callback"""
  4708. cb = cbData["cb"]
  4709. opaque = cbData["opaque"]
  4710.  
  4711. cb(self, reason, opaque)
  4712. return 0
  4713.  
  4714.  
  4715. def unregisterCloseCallback(self):
  4716. """Removes a close event callback"""
  4717. ret = libvirtmod.virConnectUnregisterCloseCallback(self._o)
  4718. if ret == -1: raise libvirtError ('virConnectUnregisterCloseCallback() failed', conn=self)
  4719.  
  4720. def registerCloseCallback(self, cb, opaque):
  4721. """Adds a close event callback, providing a notification
  4722. when a connection fails / closes"""
  4723. cbData = { "cb": cb, "conn": self, "opaque": opaque }
  4724. ret = libvirtmod.virConnectRegisterCloseCallback(self._o, cbData)
  4725. if ret == -1:
  4726. raise libvirtError ('virConnectRegisterCloseCallback() failed', conn=self)
  4727. return ret
  4728.  
  4729. def createXMLWithFiles(self, xmlDesc, files, flags=0):
  4730. """Launch a new guest domain, based on an XML description similar
  4731. to the one returned by virDomainGetXMLDesc()
  4732. This function may require privileged access to the hypervisor.
  4733. The domain is not persistent, so its definition will disappear when it
  4734. is destroyed, or if the host is restarted (see virDomainDefineXML() to
  4735. define persistent domains).
  4736.  
  4737. @files provides an array of file descriptors which will be
  4738. made available to the 'init' process of the guest. The file
  4739. handles exposed to the guest will be renumbered to start
  4740. from 3 (ie immediately following stderr). This is only
  4741. supported for guests which use container based virtualization
  4742. technology.
  4743.  
  4744. If the VIR_DOMAIN_START_PAUSED flag is set, the guest domain
  4745. will be started, but its CPUs will remain paused. The CPUs
  4746. can later be manually started using virDomainResume.
  4747.  
  4748. If the VIR_DOMAIN_START_AUTODESTROY flag is set, the guest
  4749. domain will be automatically destroyed when the virConnectPtr
  4750. object is finally released. This will also happen if the
  4751. client application crashes / loses its connection to the
  4752. libvirtd daemon. Any domains marked for auto destroy will
  4753. block attempts at migration, save-to-file, or snapshots. """
  4754. ret = libvirtmod.virDomainCreateXMLWithFiles(self._o, xmlDesc, files, flags)
  4755. if ret is None:raise libvirtError('virDomainCreateXMLWithFiles() failed', conn=self)
  4756. __tmp = virDomain(self,_obj=ret)
  4757. return __tmp
  4758.  
  4759. def getAllDomainStats(self, stats = 0, flags=0):
  4760. """Query statistics for all domains on a given connection.
  4761.  
  4762. Report statistics of various parameters for a running VM according to @stats
  4763. field. The statistics are returned as an array of structures for each queried
  4764. domain. The structure contains an array of typed parameters containing the
  4765. individual statistics. The typed parameter name for each statistic field
  4766. consists of a dot-separated string containing name of the requested group
  4767. followed by a group specific description of the statistic value.
  4768.  
  4769. The statistic groups are enabled using the @stats parameter which is a
  4770. binary-OR of enum virDomainStatsTypes. The following groups are available
  4771. (although not necessarily implemented for each hypervisor):
  4772.  
  4773. VIR_DOMAIN_STATS_STATE: Return domain state and reason for entering that
  4774. state. The typed parameter keys are in this format:
  4775. "state.state" - state of the VM, returned as int from virDomainState enum
  4776. "state.reason" - reason for entering given state, returned as int from
  4777. virDomain*Reason enum corresponding to given state.
  4778.  
  4779. Using 0 for @stats returns all stats groups supported by the given
  4780. hypervisor.
  4781.  
  4782. Specifying VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS as @flags makes
  4783. the function return error in case some of the stat types in @stats were
  4784. not recognized by the daemon.
  4785.  
  4786. Similarly to virConnectListAllDomains, @flags can contain various flags to
  4787. filter the list of domains to provide stats for.
  4788.  
  4789. VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE selects online domains while
  4790. VIR_CONNECT_GET_ALL_DOMAINS_STATS_INACTIVE selects offline ones.
  4791.  
  4792. VIR_CONNECT_GET_ALL_DOMAINS_STATS_PERSISTENT and
  4793. VIR_CONNECT_GET_ALL_DOMAINS_STATS_TRANSIENT allow to filter the list
  4794. according to their persistence.
  4795.  
  4796. To filter the list of VMs by domain state @flags can contain
  4797. VIR_CONNECT_GET_ALL_DOMAINS_STATS_RUNNING,
  4798. VIR_CONNECT_GET_ALL_DOMAINS_STATS_PAUSED,
  4799. VIR_CONNECT_GET_ALL_DOMAINS_STATS_SHUTOFF and/or
  4800. VIR_CONNECT_GET_ALL_DOMAINS_STATS_OTHER for all other states. """
  4801. ret = libvirtmod.virConnectGetAllDomainStats(self._o, stats, flags)
  4802. if ret is None:
  4803. raise libvirtError("virConnectGetAllDomainStats() failed", conn=self)
  4804.  
  4805. retlist = list()
  4806. for elem in ret:
  4807. record = (virDomain(self, _obj=elem[0]) , elem[1])
  4808. retlist.append(record)
  4809.  
  4810. return retlist
  4811.  
  4812. def domainListGetStats(self, doms, stats=0, flags=0):
  4813. """ Query statistics for given domains.
  4814.  
  4815. Report statistics of various parameters for a running VM according to @stats
  4816. field. The statistics are returned as an array of structures for each queried
  4817. domain. The structure contains an array of typed parameters containing the
  4818. individual statistics. The typed parameter name for each statistic field
  4819. consists of a dot-separated string containing name of the requested group
  4820. followed by a group specific description of the statistic value.
  4821.  
  4822. The statistic groups are enabled using the @stats parameter which is a
  4823. binary-OR of enum virDomainStatsTypes. The following groups are available
  4824. (although not necessarily implemented for each hypervisor):
  4825.  
  4826. VIR_DOMAIN_STATS_STATE: Return domain state and reason for entering that
  4827. state. The typed parameter keys are in this format:
  4828. "state.state" - state of the VM, returned as int from virDomainState enum
  4829. "state.reason" - reason for entering given state, returned as int from
  4830. virDomain*Reason enum corresponding to given state.
  4831.  
  4832. Using 0 for @stats returns all stats groups supported by the given
  4833. hypervisor.
  4834.  
  4835. Specifying VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS as @flags makes
  4836. the function return error in case some of the stat types in @stats were
  4837. not recognized by the daemon.
  4838.  
  4839. Get statistics about domains provided as a list in @doms. @stats is
  4840. a bit field selecting requested statistics types."""
  4841. domlist = list()
  4842. for dom in doms:
  4843. if not isinstance(dom, virDomain):
  4844. raise libvirtError("domain list contains non-domain elements", conn=self)
  4845.  
  4846. domlist.append(dom._o)
  4847.  
  4848. ret = libvirtmod.virDomainListGetStats(self._o, domlist, stats, flags)
  4849. if ret is None:
  4850. raise libvirtError("virDomainListGetStats() failed", conn=self)
  4851.  
  4852. retlist = list()
  4853. for elem in ret:
  4854. record = (virDomain(self, _obj=elem[0]) , elem[1])
  4855. retlist.append(record)
  4856.  
  4857. return retlist
  4858.  
  4859. class virNodeDevice(object):
  4860. def __init__(self, conn, _obj=None):
  4861. self._conn = conn
  4862. self._o = _obj
  4863.  
  4864. def __del__(self):
  4865. if self._o is not None:
  4866. libvirtmod.virNodeDeviceFree(self._o)
  4867. self._o = None
  4868.  
  4869. def connect(self):
  4870. return self._conn
  4871.  
  4872. #
  4873. # virNodeDevice functions from module libvirt
  4874. #
  4875.  
  4876. def XMLDesc(self, flags=0):
  4877. """Fetch an XML document describing all aspects of
  4878. the device. """
  4879. ret = libvirtmod.virNodeDeviceGetXMLDesc(self._o, flags)
  4880. if ret is None: raise libvirtError ('virNodeDeviceGetXMLDesc() failed')
  4881. return ret
  4882.  
  4883. def destroy(self):
  4884. """Destroy the device object. The virtual device (only works for vHBA
  4885. currently) is removed from the host operating system. This function
  4886. may require privileged access. """
  4887. ret = libvirtmod.virNodeDeviceDestroy(self._o)
  4888. if ret == -1: raise libvirtError ('virNodeDeviceDestroy() failed')
  4889. return ret
  4890.  
  4891. def detachFlags(self, driverName, flags=0):
  4892. """Detach the node device from the node itself so that it may be
  4893. assigned to a guest domain.
  4894.  
  4895. Depending on the hypervisor, this may involve operations such as
  4896. unbinding any device drivers from the device, binding the device to
  4897. a dummy device driver and resetting the device. Different backend
  4898. drivers expect the device to be bound to different dummy
  4899. devices. For example, QEMU's "kvm" backend driver (the default)
  4900. expects the device to be bound to "pci-stub", but its "vfio"
  4901. backend driver expects the device to be bound to "vfio-pci".
  4902.  
  4903. If the device is currently in use by the node, this method may
  4904. fail.
  4905.  
  4906. Once the device is not assigned to any guest, it may be re-attached
  4907. to the node using the virNodeDeviceReAttach() method. """
  4908. ret = libvirtmod.virNodeDeviceDetachFlags(self._o, driverName, flags)
  4909. if ret == -1: raise libvirtError ('virNodeDeviceDetachFlags() failed')
  4910. return ret
  4911.  
  4912. def dettach(self):
  4913. """Dettach the node device from the node itself so that it may be
  4914. assigned to a guest domain.
  4915.  
  4916. Depending on the hypervisor, this may involve operations such
  4917. as unbinding any device drivers from the device, binding the
  4918. device to a dummy device driver and resetting the device.
  4919.  
  4920. If the device is currently in use by the node, this method may
  4921. fail.
  4922.  
  4923. Once the device is not assigned to any guest, it may be re-attached
  4924. to the node using the virNodeDeviceReattach() method.
  4925.  
  4926. If the caller needs control over which backend driver will be used
  4927. during PCI device assignment (to use something other than the
  4928. default, for example VFIO), the newer virNodeDeviceDetachFlags()
  4929. API should be used instead. """
  4930. ret = libvirtmod.virNodeDeviceDettach(self._o)
  4931. if ret == -1: raise libvirtError ('virNodeDeviceDettach() failed')
  4932. return ret
  4933.  
  4934. #
  4935. # virNodeDevice functions from module python
  4936. #
  4937.  
  4938. def listCaps(self):
  4939. """list the node device's capabilities """
  4940. ret = libvirtmod.virNodeDeviceListCaps(self._o)
  4941. if ret is None: raise libvirtError ('virNodeDeviceListCaps() failed')
  4942. return ret
  4943.  
  4944. #
  4945. # virNodeDevice functions from module libvirt
  4946. #
  4947.  
  4948. def name(self):
  4949. """Just return the device name """
  4950. ret = libvirtmod.virNodeDeviceGetName(self._o)
  4951. return ret
  4952.  
  4953. def numOfCaps(self):
  4954. """Accessor for the number of capabilities supported by the device. """
  4955. ret = libvirtmod.virNodeDeviceNumOfCaps(self._o)
  4956. if ret == -1: raise libvirtError ('virNodeDeviceNumOfCaps() failed')
  4957. return ret
  4958.  
  4959. def parent(self):
  4960. """Accessor for the parent of the device """
  4961. ret = libvirtmod.virNodeDeviceGetParent(self._o)
  4962. return ret
  4963.  
  4964. def reAttach(self):
  4965. """Re-attach a previously dettached node device to the node so that it
  4966. may be used by the node again.
  4967.  
  4968. Depending on the hypervisor, this may involve operations such
  4969. as resetting the device, unbinding it from a dummy device driver
  4970. and binding it to its appropriate driver.
  4971.  
  4972. If the device is currently in use by a guest, this method may fail. """
  4973. ret = libvirtmod.virNodeDeviceReAttach(self._o)
  4974. if ret == -1: raise libvirtError ('virNodeDeviceReAttach() failed')
  4975. return ret
  4976.  
  4977. def reset(self):
  4978. """Reset a previously dettached node device to the node before or
  4979. after assigning it to a guest.
  4980.  
  4981. The exact reset semantics depends on the hypervisor and device
  4982. type but, for example, KVM will attempt to reset PCI devices with
  4983. a Function Level Reset, Secondary Bus Reset or a Power Management
  4984. D-State reset.
  4985.  
  4986. If the reset will affect other devices which are currently in use,
  4987. this function may fail. """
  4988. ret = libvirtmod.virNodeDeviceReset(self._o)
  4989. if ret == -1: raise libvirtError ('virNodeDeviceReset() failed')
  4990. return ret
  4991.  
  4992. class virSecret(object):
  4993. def __init__(self, conn, _obj=None):
  4994. self._conn = conn
  4995. self._o = _obj
  4996.  
  4997. def __del__(self):
  4998. if self._o is not None:
  4999. libvirtmod.virSecretFree(self._o)
  5000. self._o = None
  5001.  
  5002. def connect(self):
  5003. return self._conn
  5004.  
  5005. #
  5006. # virSecret functions from module python
  5007. #
  5008.  
  5009. def UUID(self):
  5010. """Extract the UUID unique Identifier of a secret. """
  5011. ret = libvirtmod.virSecretGetUUID(self._o)
  5012. if ret is None: raise libvirtError ('virSecretGetUUID() failed')
  5013. return ret
  5014.  
  5015. def UUIDString(self):
  5016. """Fetch globally unique ID of the secret as a string. """
  5017. ret = libvirtmod.virSecretGetUUIDString(self._o)
  5018. if ret is None: raise libvirtError ('virSecretGetUUIDString() failed')
  5019. return ret
  5020.  
  5021. #
  5022. # virSecret functions from module libvirt
  5023. #
  5024.  
  5025. def XMLDesc(self, flags=0):
  5026. """Fetches an XML document describing attributes of the secret. """
  5027. ret = libvirtmod.virSecretGetXMLDesc(self._o, flags)
  5028. if ret is None: raise libvirtError ('virSecretGetXMLDesc() failed')
  5029. return ret
  5030.  
  5031. def setValue(self, value, flags=0):
  5032. """Associates a value with a secret. """
  5033. ret = libvirtmod.virSecretSetValue(self._o, value, flags)
  5034. if ret == -1: raise libvirtError ('virSecretSetValue() failed')
  5035. return ret
  5036.  
  5037. def undefine(self):
  5038. """Deletes the specified secret. This does not free the associated
  5039. virSecretPtr object. """
  5040. ret = libvirtmod.virSecretUndefine(self._o)
  5041. if ret == -1: raise libvirtError ('virSecretUndefine() failed')
  5042. return ret
  5043.  
  5044. def usageID(self):
  5045. """Get the unique identifier of the object with which this
  5046. secret is to be used. The format of the identifier is
  5047. dependant on the usage type of the secret. For a secret
  5048. with a usage type of VIR_SECRET_USAGE_TYPE_VOLUME the
  5049. identifier will be a fully qualfied path name. The
  5050. identifiers are intended to be unique within the set of
  5051. all secrets sharing the same usage type. ie, there shall
  5052. only ever be one secret for each volume path. """
  5053. ret = libvirtmod.virSecretGetUsageID(self._o)
  5054. return ret
  5055.  
  5056. def usageType(self):
  5057. """Get the type of object which uses this secret. The returned
  5058. value is one of the constants defined in the virSecretUsageType
  5059. enumeration. More values may be added to this enumeration in
  5060. the future, so callers should expect to see usage types they
  5061. do not explicitly know about. """
  5062. ret = libvirtmod.virSecretGetUsageType(self._o)
  5063. return ret
  5064.  
  5065. def value(self, flags=0):
  5066. """Fetches the value associated with a secret. """
  5067. ret = libvirtmod.virSecretGetValue(self._o, flags)
  5068. if ret is None: raise libvirtError ('virSecretGetValue() failed')
  5069. return ret
  5070.  
  5071. class virNWFilter(object):
  5072. def __init__(self, conn, _obj=None):
  5073. self._conn = conn
  5074. self._o = _obj
  5075.  
  5076. def __del__(self):
  5077. if self._o is not None:
  5078. libvirtmod.virNWFilterFree(self._o)
  5079. self._o = None
  5080.  
  5081. def connect(self):
  5082. return self._conn
  5083.  
  5084. #
  5085. # virNWFilter functions from module python
  5086. #
  5087.  
  5088. def UUID(self):
  5089. """Extract the UUID unique Identifier of a network filter. """
  5090. ret = libvirtmod.virNWFilterGetUUID(self._o)
  5091. if ret is None: raise libvirtError ('virNWFilterGetUUID() failed')
  5092. return ret
  5093.  
  5094. def UUIDString(self):
  5095. """Fetch globally unique ID of the network filter as a string. """
  5096. ret = libvirtmod.virNWFilterGetUUIDString(self._o)
  5097. if ret is None: raise libvirtError ('virNWFilterGetUUIDString() failed')
  5098. return ret
  5099.  
  5100. #
  5101. # virNWFilter functions from module libvirt
  5102. #
  5103.  
  5104. def XMLDesc(self, flags=0):
  5105. """Provide an XML description of the network filter. The description may be
  5106. reused later to redefine the network filter with virNWFilterCreateXML(). """
  5107. ret = libvirtmod.virNWFilterGetXMLDesc(self._o, flags)
  5108. if ret is None: raise libvirtError ('virNWFilterGetXMLDesc() failed')
  5109. return ret
  5110.  
  5111. def name(self):
  5112. """Get the public name for the network filter """
  5113. ret = libvirtmod.virNWFilterGetName(self._o)
  5114. return ret
  5115.  
  5116. def undefine(self):
  5117. """Undefine the nwfilter object. This call will not succeed if
  5118. a running VM is referencing the filter. This does not free the
  5119. associated virNWFilterPtr object. """
  5120. ret = libvirtmod.virNWFilterUndefine(self._o)
  5121. if ret == -1: raise libvirtError ('virNWFilterUndefine() failed')
  5122. return ret
  5123.  
  5124. class virStream(object):
  5125. def __init__(self, conn, _obj=None):
  5126. self._conn = conn
  5127. self._o = _obj
  5128.  
  5129. def connect(self):
  5130. return self._conn
  5131.  
  5132. #
  5133. # virStream functions from module libvirt
  5134. #
  5135.  
  5136. def abort(self):
  5137. """Request that the in progress data transfer be cancelled
  5138. abnormally before the end of the stream has been reached.
  5139. For output streams this can be used to inform the driver
  5140. that the stream is being terminated early. For input
  5141. streams this can be used to inform the driver that it
  5142. should stop sending data. """
  5143. ret = libvirtmod.virStreamAbort(self._o)
  5144. if ret == -1: raise libvirtError ('virStreamAbort() failed')
  5145. return ret
  5146.  
  5147. def eventRemoveCallback(self):
  5148. """Remove an event callback from the stream """
  5149. ret = libvirtmod.virStreamEventRemoveCallback(self._o)
  5150. if ret == -1: raise libvirtError ('virStreamEventRemoveCallback() failed')
  5151. return ret
  5152.  
  5153. def eventUpdateCallback(self, events):
  5154. """Changes the set of events to monitor for a stream. This allows
  5155. for event notification to be changed without having to
  5156. unregister & register the callback completely. This method
  5157. is guaranteed to succeed if a callback is already registered """
  5158. ret = libvirtmod.virStreamEventUpdateCallback(self._o, events)
  5159. if ret == -1: raise libvirtError ('virStreamEventUpdateCallback() failed')
  5160. return ret
  5161.  
  5162. def finish(self):
  5163. """Indicate that there is no further data to be transmitted
  5164. on the stream. For output streams this should be called once
  5165. all data has been written. For input streams this should be
  5166. called once virStreamRecv returns end-of-file.
  5167.  
  5168. This method is a synchronization point for all asynchronous
  5169. errors, so if this returns a success code the application can
  5170. be sure that all data has been successfully processed. """
  5171. ret = libvirtmod.virStreamFinish(self._o)
  5172. if ret == -1: raise libvirtError ('virStreamFinish() failed')
  5173. return ret
  5174.  
  5175. #
  5176. # virStream methods from virStream.py (hand coded)
  5177. #
  5178. def __del__(self):
  5179. try:
  5180. if self.cb:
  5181. libvirtmod.virStreamEventRemoveCallback(self._o)
  5182. except AttributeError:
  5183. pass
  5184.  
  5185. if self._o is not None:
  5186. libvirtmod.virStreamFree(self._o)
  5187. self._o = None
  5188.  
  5189. def _dispatchStreamEventCallback(self, events, cbData):
  5190. """
  5191. Dispatches events to python user's stream event callbacks
  5192. """
  5193. cb = cbData["cb"]
  5194. opaque = cbData["opaque"]
  5195.  
  5196. cb(self, events, opaque)
  5197. return 0
  5198.  
  5199. def eventAddCallback(self, events, cb, opaque):
  5200. self.cb = cb
  5201. cbData = {"stream": self, "cb" : cb, "opaque" : opaque}
  5202. ret = libvirtmod.virStreamEventAddCallback(self._o, events, cbData)
  5203. if ret == -1: raise libvirtError ('virStreamEventAddCallback() failed')
  5204.  
  5205. def recvAll(self, handler, opaque):
  5206. """Receive the entire data stream, sending the data to the
  5207. requested data sink. This is simply a convenient alternative
  5208. to virStreamRecv, for apps that do blocking-I/O.
  5209.  
  5210. A hypothetical handler function looks like:
  5211.  
  5212. def handler(stream, # virStream instance
  5213. buf, # string containing received data
  5214. opaque): # extra data passed to recvAll as opaque
  5215. fd = opaque
  5216. return os.write(fd, buf)
  5217. """
  5218. while True:
  5219. got = self.recv(1024*64)
  5220. if got == -2:
  5221. raise libvirtError("cannot use recvAll with "
  5222. "nonblocking stream")
  5223. if len(got) == 0:
  5224. break
  5225.  
  5226. try:
  5227. ret = handler(self, got, opaque)
  5228. if type(ret) is int and ret < 0:
  5229. raise RuntimeError("recvAll handler returned %d" % ret)
  5230. except Exception:
  5231. e = sys.exc_info()[1]
  5232. try:
  5233. self.abort()
  5234. except:
  5235. pass
  5236. raise e
  5237.  
  5238. def sendAll(self, handler, opaque):
  5239. """
  5240. Send the entire data stream, reading the data from the
  5241. requested data source. This is simply a convenient alternative
  5242. to virStreamSend, for apps that do blocking-I/O.
  5243.  
  5244. A hypothetical handler function looks like:
  5245.  
  5246. def handler(stream, # virStream instance
  5247. nbytes, # int amt of data to read
  5248. opaque): # extra data passed to recvAll as opaque
  5249. fd = opaque
  5250. return os.read(fd, nbytes)
  5251. """
  5252. while True:
  5253. try:
  5254. got = handler(self, 1024*64, opaque)
  5255. except:
  5256. e = sys.exc_info()[1]
  5257. try:
  5258. self.abort()
  5259. except:
  5260. pass
  5261. raise e
  5262.  
  5263. if got == "":
  5264. break
  5265.  
  5266. ret = self.send(got)
  5267. if ret == -2:
  5268. raise libvirtError("cannot use sendAll with "
  5269. "nonblocking stream")
  5270.  
  5271. def recv(self, nbytes):
  5272. """Reads a series of bytes from the stream. This method may
  5273. block the calling application for an arbitrary amount
  5274. of time.
  5275.  
  5276. Errors are not guaranteed to be reported synchronously
  5277. with the call, but may instead be delayed until a
  5278. subsequent call.
  5279.  
  5280. On success, the received data is returned. On failure, an
  5281. exception is raised. If the stream is a NONBLOCK stream and
  5282. the request would block, integer -2 is returned.
  5283. """
  5284. ret = libvirtmod.virStreamRecv(self._o, nbytes)
  5285. if ret is None: raise libvirtError ('virStreamRecv() failed')
  5286. return ret
  5287.  
  5288. def send(self, data):
  5289. """Write a series of bytes to the stream. This method may
  5290. block the calling application for an arbitrary amount
  5291. of time. Once an application has finished sending data
  5292. it should call virStreamFinish to wait for successful
  5293. confirmation from the driver, or detect any error
  5294.  
  5295. This method may not be used if a stream source has been
  5296. registered
  5297.  
  5298. Errors are not guaranteed to be reported synchronously
  5299. with the call, but may instead be delayed until a
  5300. subsequent call.
  5301. """
  5302. ret = libvirtmod.virStreamSend(self._o, data)
  5303. if ret == -1: raise libvirtError ('virStreamSend() failed')
  5304. return ret
  5305.  
  5306. class virDomainSnapshot(object):
  5307. def __init__(self, dom, _obj=None):
  5308. self._dom = dom
  5309. self._conn = dom.connect()
  5310. self._o = _obj
  5311.  
  5312. def __del__(self):
  5313. if self._o is not None:
  5314. libvirtmod.virDomainSnapshotFree(self._o)
  5315. self._o = None
  5316.  
  5317. def connect(self):
  5318. return self._conn
  5319.  
  5320. def domain(self):
  5321. return self._dom
  5322.  
  5323. #
  5324. # virDomainSnapshot functions from module libvirt
  5325. #
  5326.  
  5327. def delete(self, flags=0):
  5328. """Delete the snapshot.
  5329.  
  5330. If @flags is 0, then just this snapshot is deleted, and changes
  5331. from this snapshot are automatically merged into children
  5332. snapshots. If @flags includes VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN,
  5333. then this snapshot and any descendant snapshots are deleted. If
  5334. @flags includes VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY, then any
  5335. descendant snapshots are deleted, but this snapshot remains. These
  5336. two flags are mutually exclusive.
  5337.  
  5338. If @flags includes VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY, then
  5339. any snapshot metadata tracked by libvirt is removed while keeping
  5340. the snapshot contents intact; if a hypervisor does not require any
  5341. libvirt metadata to track snapshots, then this flag is silently
  5342. ignored. """
  5343. ret = libvirtmod.virDomainSnapshotDelete(self._o, flags)
  5344. if ret == -1: raise libvirtError ('virDomainSnapshotDelete() failed')
  5345. return ret
  5346.  
  5347. def getName(self):
  5348. """Get the public name for that snapshot """
  5349. ret = libvirtmod.virDomainSnapshotGetName(self._o)
  5350. if ret is None: raise libvirtError ('virDomainSnapshotGetName() failed')
  5351. return ret
  5352.  
  5353. def getParent(self, flags=0):
  5354. """Get the parent snapshot for @snapshot, if any.
  5355.  
  5356. virDomainSnapshotFree should be used to free the resources after the
  5357. snapshot object is no longer needed. """
  5358. ret = libvirtmod.virDomainSnapshotGetParent(self._o, flags)
  5359. if ret is None:raise libvirtError('virDomainSnapshotGetParent() failed', dom=self._dom)
  5360. __tmp = virDomainSnapshot(self,_obj=ret)
  5361. return __tmp
  5362.  
  5363. def getXMLDesc(self, flags=0):
  5364. """Provide an XML description of the domain snapshot.
  5365.  
  5366. No security-sensitive data will be included unless @flags contains
  5367. VIR_DOMAIN_XML_SECURE; this flag is rejected on read-only
  5368. connections. For this API, @flags should not contain either
  5369. VIR_DOMAIN_XML_INACTIVE or VIR_DOMAIN_XML_UPDATE_CPU. """
  5370. ret = libvirtmod.virDomainSnapshotGetXMLDesc(self._o, flags)
  5371. if ret is None: raise libvirtError ('virDomainSnapshotGetXMLDesc() failed')
  5372. return ret
  5373.  
  5374. def hasMetadata(self, flags=0):
  5375. """Determine if the given snapshot is associated with libvirt metadata
  5376. that would prevent the deletion of the domain. """
  5377. ret = libvirtmod.virDomainSnapshotHasMetadata(self._o, flags)
  5378. if ret == -1: raise libvirtError ('virDomainSnapshotHasMetadata() failed')
  5379. return ret
  5380.  
  5381. def isCurrent(self, flags=0):
  5382. """Determine if the given snapshot is the domain's current snapshot. See
  5383. also virDomainHasCurrentSnapshot(). """
  5384. ret = libvirtmod.virDomainSnapshotIsCurrent(self._o, flags)
  5385. if ret == -1: raise libvirtError ('virDomainSnapshotIsCurrent() failed')
  5386. return ret
  5387.  
  5388. #
  5389. # virDomainSnapshot functions from module python
  5390. #
  5391.  
  5392. def listChildrenNames(self, flags=0):
  5393. """collect the list of child snapshot names for the given snapshot """
  5394. ret = libvirtmod.virDomainSnapshotListChildrenNames(self._o, flags)
  5395. if ret is None: raise libvirtError ('virDomainSnapshotListChildrenNames() failed')
  5396. return ret
  5397.  
  5398. #
  5399. # virDomainSnapshot functions from module libvirt
  5400. #
  5401.  
  5402. def numChildren(self, flags=0):
  5403. """Provides the number of child snapshots for this domain snapshot.
  5404.  
  5405. By default, this command covers only direct children; it is also possible
  5406. to expand things to cover all descendants, when @flags includes
  5407. VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS. Also, some filters are provided in
  5408. groups, where each group contains bits that describe mutually exclusive
  5409. attributes of a snapshot, and where all bits within a group describe
  5410. all possible snapshots. Some hypervisors might reject explicit bits
  5411. from a group where the hypervisor cannot make a distinction. For a
  5412. group supported by a given hypervisor, the behavior when no bits of a
  5413. group are set is identical to the behavior when all bits in that group
  5414. are set. When setting bits from more than one group, it is possible to
  5415. select an impossible combination, in that case a hypervisor may return
  5416. either 0 or an error.
  5417.  
  5418. The first group of @flags is VIR_DOMAIN_SNAPSHOT_LIST_LEAVES and
  5419. VIR_DOMAIN_SNAPSHOT_LIST_NO_LEAVES, to filter based on snapshots that
  5420. have no further children (a leaf snapshot).
  5421.  
  5422. The next group of @flags is VIR_DOMAIN_SNAPSHOT_LIST_METADATA and
  5423. VIR_DOMAIN_SNAPSHOT_LIST_NO_METADATA, for filtering snapshots based on
  5424. whether they have metadata that would prevent the removal of the last
  5425. reference to a domain.
  5426.  
  5427. The next group of @flags is VIR_DOMAIN_SNAPSHOT_LIST_INACTIVE,
  5428. VIR_DOMAIN_SNAPSHOT_LIST_ACTIVE, and VIR_DOMAIN_SNAPSHOT_LIST_DISK_ONLY,
  5429. for filtering snapshots based on what domain state is tracked by the
  5430. snapshot.
  5431.  
  5432. The next group of @flags is VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL and
  5433. VIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL, for filtering snapshots based on
  5434. whether the snapshot is stored inside the disk images or as
  5435. additional files. """
  5436. ret = libvirtmod.virDomainSnapshotNumChildren(self._o, flags)
  5437. if ret == -1: raise libvirtError ('virDomainSnapshotNumChildren() failed')
  5438. return ret
  5439.  
  5440. #
  5441. # virDomainSnapshot methods from virDomainSnapshot.py (hand coded)
  5442. #
  5443. def getConnect(self):
  5444. """Get the connection that owns the domain that a snapshot was created for"""
  5445. return self.connect()
  5446.  
  5447. def getDomain(self):
  5448. """Get the domain that a snapshot was created for"""
  5449. return self.domain()
  5450.  
  5451. def listAllChildren(self, flags=0):
  5452. """List all child snapshots and returns a list of snapshot objects"""
  5453. ret = libvirtmod.virDomainSnapshotListAllChildren(self._o, flags)
  5454. if ret is None:
  5455. raise libvirtError("virDomainSnapshotListAllChildren() failed", conn=self)
  5456.  
  5457. retlist = list()
  5458. for snapptr in ret:
  5459. retlist.append(virDomainSnapshot(self, _obj=snapptr))
  5460.  
  5461. return retlist
  5462.  
  5463. # virBlkioParameterType
  5464. VIR_DOMAIN_BLKIO_PARAM_INT = 1
  5465. VIR_DOMAIN_BLKIO_PARAM_UINT = 2
  5466. VIR_DOMAIN_BLKIO_PARAM_LLONG = 3
  5467. VIR_DOMAIN_BLKIO_PARAM_ULLONG = 4
  5468. VIR_DOMAIN_BLKIO_PARAM_DOUBLE = 5
  5469. VIR_DOMAIN_BLKIO_PARAM_BOOLEAN = 6
  5470.  
  5471. # virCPUCompareResult
  5472. VIR_CPU_COMPARE_ERROR = -1
  5473. VIR_CPU_COMPARE_INCOMPATIBLE = 0
  5474. VIR_CPU_COMPARE_IDENTICAL = 1
  5475. VIR_CPU_COMPARE_SUPERSET = 2
  5476.  
  5477. # virConnectBaselineCPUFlags
  5478. VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES = 1
  5479.  
  5480. # virConnectCloseReason
  5481. VIR_CONNECT_CLOSE_REASON_ERROR = 0
  5482. VIR_CONNECT_CLOSE_REASON_EOF = 1
  5483. VIR_CONNECT_CLOSE_REASON_KEEPALIVE = 2
  5484. VIR_CONNECT_CLOSE_REASON_CLIENT = 3
  5485.  
  5486. # virConnectCompareCPUFlags
  5487. VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE = 1
  5488.  
  5489. # virConnectCredentialType
  5490. VIR_CRED_USERNAME = 1
  5491. VIR_CRED_AUTHNAME = 2
  5492. VIR_CRED_LANGUAGE = 3
  5493. VIR_CRED_CNONCE = 4
  5494. VIR_CRED_PASSPHRASE = 5
  5495. VIR_CRED_ECHOPROMPT = 6
  5496. VIR_CRED_NOECHOPROMPT = 7
  5497. VIR_CRED_REALM = 8
  5498. VIR_CRED_EXTERNAL = 9
  5499.  
  5500. # virConnectDomainEventAgentLifecycleReason
  5501. VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_REASON_UNKNOWN = 0
  5502. VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_REASON_DOMAIN_STARTED = 1
  5503. VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_REASON_CHANNEL = 2
  5504.  
  5505. # virConnectDomainEventAgentLifecycleState
  5506. VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_STATE_CONNECTED = 1
  5507. VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_STATE_DISCONNECTED = 2
  5508.  
  5509. # virConnectDomainEventBlockJobStatus
  5510. VIR_DOMAIN_BLOCK_JOB_COMPLETED = 0
  5511. VIR_DOMAIN_BLOCK_JOB_FAILED = 1
  5512. VIR_DOMAIN_BLOCK_JOB_CANCELED = 2
  5513. VIR_DOMAIN_BLOCK_JOB_READY = 3
  5514.  
  5515. # virConnectDomainEventDiskChangeReason
  5516. VIR_DOMAIN_EVENT_DISK_CHANGE_MISSING_ON_START = 0
  5517. VIR_DOMAIN_EVENT_DISK_DROP_MISSING_ON_START = 1
  5518.  
  5519. # virConnectFlags
  5520. VIR_CONNECT_RO = 1
  5521. VIR_CONNECT_NO_ALIASES = 2
  5522.  
  5523. # virConnectGetAllDomainStatsFlags
  5524. VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE = 1
  5525. VIR_CONNECT_GET_ALL_DOMAINS_STATS_INACTIVE = 2
  5526. VIR_CONNECT_GET_ALL_DOMAINS_STATS_PERSISTENT = 4
  5527. VIR_CONNECT_GET_ALL_DOMAINS_STATS_TRANSIENT = 8
  5528. VIR_CONNECT_GET_ALL_DOMAINS_STATS_RUNNING = 16
  5529. VIR_CONNECT_GET_ALL_DOMAINS_STATS_PAUSED = 32
  5530. VIR_CONNECT_GET_ALL_DOMAINS_STATS_SHUTOFF = 64
  5531. VIR_CONNECT_GET_ALL_DOMAINS_STATS_OTHER = 128
  5532. VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING = 1073741824
  5533. VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS = 2147483648
  5534.  
  5535. # virConnectListAllDomainsFlags
  5536. VIR_CONNECT_LIST_DOMAINS_ACTIVE = 1
  5537. VIR_CONNECT_LIST_DOMAINS_INACTIVE = 2
  5538. VIR_CONNECT_LIST_DOMAINS_PERSISTENT = 4
  5539. VIR_CONNECT_LIST_DOMAINS_TRANSIENT = 8
  5540. VIR_CONNECT_LIST_DOMAINS_RUNNING = 16
  5541. VIR_CONNECT_LIST_DOMAINS_PAUSED = 32
  5542. VIR_CONNECT_LIST_DOMAINS_SHUTOFF = 64
  5543. VIR_CONNECT_LIST_DOMAINS_OTHER = 128
  5544. VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE = 256
  5545. VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE = 512
  5546. VIR_CONNECT_LIST_DOMAINS_AUTOSTART = 1024
  5547. VIR_CONNECT_LIST_DOMAINS_NO_AUTOSTART = 2048
  5548. VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT = 4096
  5549. VIR_CONNECT_LIST_DOMAINS_NO_SNAPSHOT = 8192
  5550.  
  5551. # virConnectListAllInterfacesFlags
  5552. VIR_CONNECT_LIST_INTERFACES_INACTIVE = 1
  5553. VIR_CONNECT_LIST_INTERFACES_ACTIVE = 2
  5554.  
  5555. # virConnectListAllNetworksFlags
  5556. VIR_CONNECT_LIST_NETWORKS_INACTIVE = 1
  5557. VIR_CONNECT_LIST_NETWORKS_ACTIVE = 2
  5558. VIR_CONNECT_LIST_NETWORKS_PERSISTENT = 4
  5559. VIR_CONNECT_LIST_NETWORKS_TRANSIENT = 8
  5560. VIR_CONNECT_LIST_NETWORKS_AUTOSTART = 16
  5561. VIR_CONNECT_LIST_NETWORKS_NO_AUTOSTART = 32
  5562.  
  5563. # virConnectListAllNodeDeviceFlags
  5564. VIR_CONNECT_LIST_NODE_DEVICES_CAP_SYSTEM = 1
  5565. VIR_CONNECT_LIST_NODE_DEVICES_CAP_PCI_DEV = 2
  5566. VIR_CONNECT_LIST_NODE_DEVICES_CAP_USB_DEV = 4
  5567. VIR_CONNECT_LIST_NODE_DEVICES_CAP_USB_INTERFACE = 8
  5568. VIR_CONNECT_LIST_NODE_DEVICES_CAP_NET = 16
  5569. VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_HOST = 32
  5570. VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_TARGET = 64
  5571. VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI = 128
  5572. VIR_CONNECT_LIST_NODE_DEVICES_CAP_STORAGE = 256
  5573. VIR_CONNECT_LIST_NODE_DEVICES_CAP_FC_HOST = 512
  5574. VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS = 1024
  5575. VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC = 2048
  5576.  
  5577. # virConnectListAllSecretsFlags
  5578. VIR_CONNECT_LIST_SECRETS_EPHEMERAL = 1
  5579. VIR_CONNECT_LIST_SECRETS_NO_EPHEMERAL = 2
  5580. VIR_CONNECT_LIST_SECRETS_PRIVATE = 4
  5581. VIR_CONNECT_LIST_SECRETS_NO_PRIVATE = 8
  5582.  
  5583. # virConnectListAllStoragePoolsFlags
  5584. VIR_CONNECT_LIST_STORAGE_POOLS_INACTIVE = 1
  5585. VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE = 2
  5586. VIR_CONNECT_LIST_STORAGE_POOLS_PERSISTENT = 4
  5587. VIR_CONNECT_LIST_STORAGE_POOLS_TRANSIENT = 8
  5588. VIR_CONNECT_LIST_STORAGE_POOLS_AUTOSTART = 16
  5589. VIR_CONNECT_LIST_STORAGE_POOLS_NO_AUTOSTART = 32
  5590. VIR_CONNECT_LIST_STORAGE_POOLS_DIR = 64
  5591. VIR_CONNECT_LIST_STORAGE_POOLS_FS = 128
  5592. VIR_CONNECT_LIST_STORAGE_POOLS_NETFS = 256
  5593. VIR_CONNECT_LIST_STORAGE_POOLS_LOGICAL = 512
  5594. VIR_CONNECT_LIST_STORAGE_POOLS_DISK = 1024
  5595. VIR_CONNECT_LIST_STORAGE_POOLS_ISCSI = 2048
  5596. VIR_CONNECT_LIST_STORAGE_POOLS_SCSI = 4096
  5597. VIR_CONNECT_LIST_STORAGE_POOLS_MPATH = 8192
  5598. VIR_CONNECT_LIST_STORAGE_POOLS_RBD = 16384
  5599. VIR_CONNECT_LIST_STORAGE_POOLS_SHEEPDOG = 32768
  5600. VIR_CONNECT_LIST_STORAGE_POOLS_GLUSTER = 65536
  5601. VIR_CONNECT_LIST_STORAGE_POOLS_ZFS = 131072
  5602.  
  5603. # virDomainBlockCommitFlags
  5604. VIR_DOMAIN_BLOCK_COMMIT_SHALLOW = 1
  5605. VIR_DOMAIN_BLOCK_COMMIT_DELETE = 2
  5606. VIR_DOMAIN_BLOCK_COMMIT_ACTIVE = 4
  5607. VIR_DOMAIN_BLOCK_COMMIT_RELATIVE = 8
  5608.  
  5609. # virDomainBlockCopyFlags
  5610. VIR_DOMAIN_BLOCK_COPY_SHALLOW = 1
  5611. VIR_DOMAIN_BLOCK_COPY_REUSE_EXT = 2
  5612.  
  5613. # virDomainBlockJobAbortFlags
  5614. VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC = 1
  5615. VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT = 2
  5616.  
  5617. # virDomainBlockJobType
  5618. VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN = 0
  5619. VIR_DOMAIN_BLOCK_JOB_TYPE_PULL = 1
  5620. VIR_DOMAIN_BLOCK_JOB_TYPE_COPY = 2
  5621. VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT = 3
  5622. VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT = 4
  5623.  
  5624. # virDomainBlockRebaseFlags
  5625. VIR_DOMAIN_BLOCK_REBASE_SHALLOW = 1
  5626. VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT = 2
  5627. VIR_DOMAIN_BLOCK_REBASE_COPY_RAW = 4
  5628. VIR_DOMAIN_BLOCK_REBASE_COPY = 8
  5629. VIR_DOMAIN_BLOCK_REBASE_RELATIVE = 16
  5630. VIR_DOMAIN_BLOCK_REBASE_COPY_DEV = 32
  5631.  
  5632. # virDomainBlockResizeFlags
  5633. VIR_DOMAIN_BLOCK_RESIZE_BYTES = 1
  5634.  
  5635. # virDomainBlockedReason
  5636. VIR_DOMAIN_BLOCKED_UNKNOWN = 0
  5637.  
  5638. # virDomainChannelFlags
  5639. VIR_DOMAIN_CHANNEL_FORCE = 1
  5640.  
  5641. # virDomainConsoleFlags
  5642. VIR_DOMAIN_CONSOLE_FORCE = 1
  5643. VIR_DOMAIN_CONSOLE_SAFE = 2
  5644.  
  5645. # virDomainControlState
  5646. VIR_DOMAIN_CONTROL_OK = 0
  5647. VIR_DOMAIN_CONTROL_JOB = 1
  5648. VIR_DOMAIN_CONTROL_OCCUPIED = 2
  5649. VIR_DOMAIN_CONTROL_ERROR = 3
  5650.  
  5651. # virDomainCoreDumpFlags
  5652. VIR_DUMP_CRASH = 1
  5653. VIR_DUMP_LIVE = 2
  5654. VIR_DUMP_BYPASS_CACHE = 4
  5655. VIR_DUMP_RESET = 8
  5656. VIR_DUMP_MEMORY_ONLY = 16
  5657.  
  5658. # virDomainCoreDumpFormat
  5659. VIR_DOMAIN_CORE_DUMP_FORMAT_RAW = 0
  5660. VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_ZLIB = 1
  5661. VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_LZO = 2
  5662. VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_SNAPPY = 3
  5663.  
  5664. # virDomainCrashedReason
  5665. VIR_DOMAIN_CRASHED_UNKNOWN = 0
  5666. VIR_DOMAIN_CRASHED_PANICKED = 1
  5667.  
  5668. # virDomainCreateFlags
  5669. VIR_DOMAIN_NONE = 0
  5670. VIR_DOMAIN_START_PAUSED = 1
  5671. VIR_DOMAIN_START_AUTODESTROY = 2
  5672. VIR_DOMAIN_START_BYPASS_CACHE = 4
  5673. VIR_DOMAIN_START_FORCE_BOOT = 8
  5674.  
  5675. # virDomainDestroyFlagsValues
  5676. VIR_DOMAIN_DESTROY_DEFAULT = 0
  5677. VIR_DOMAIN_DESTROY_GRACEFUL = 1
  5678.  
  5679. # virDomainDeviceModifyFlags
  5680. VIR_DOMAIN_DEVICE_MODIFY_CURRENT = 0
  5681. VIR_DOMAIN_DEVICE_MODIFY_LIVE = 1
  5682. VIR_DOMAIN_DEVICE_MODIFY_CONFIG = 2
  5683. VIR_DOMAIN_DEVICE_MODIFY_FORCE = 4
  5684.  
  5685. # virDomainDiskErrorCode
  5686. VIR_DOMAIN_DISK_ERROR_NONE = 0
  5687. VIR_DOMAIN_DISK_ERROR_UNSPEC = 1
  5688. VIR_DOMAIN_DISK_ERROR_NO_SPACE = 2
  5689.  
  5690. # virDomainEventCrashedDetailType
  5691. VIR_DOMAIN_EVENT_CRASHED_PANICKED = 0
  5692.  
  5693. # virDomainEventDefinedDetailType
  5694. VIR_DOMAIN_EVENT_DEFINED_ADDED = 0
  5695. VIR_DOMAIN_EVENT_DEFINED_UPDATED = 1
  5696.  
  5697. # virDomainEventGraphicsAddressType
  5698. VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4 = 0
  5699. VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6 = 1
  5700. VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_UNIX = 2
  5701.  
  5702. # virDomainEventGraphicsPhase
  5703. VIR_DOMAIN_EVENT_GRAPHICS_CONNECT = 0
  5704. VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE = 1
  5705. VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT = 2
  5706.  
  5707. # virDomainEventID
  5708. VIR_DOMAIN_EVENT_ID_LIFECYCLE = 0
  5709. VIR_DOMAIN_EVENT_ID_REBOOT = 1
  5710. VIR_DOMAIN_EVENT_ID_RTC_CHANGE = 2
  5711. VIR_DOMAIN_EVENT_ID_WATCHDOG = 3
  5712. VIR_DOMAIN_EVENT_ID_IO_ERROR = 4
  5713. VIR_DOMAIN_EVENT_ID_GRAPHICS = 5
  5714. VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON = 6
  5715. VIR_DOMAIN_EVENT_ID_CONTROL_ERROR = 7
  5716. VIR_DOMAIN_EVENT_ID_BLOCK_JOB = 8
  5717. VIR_DOMAIN_EVENT_ID_DISK_CHANGE = 9
  5718. VIR_DOMAIN_EVENT_ID_TRAY_CHANGE = 10
  5719. VIR_DOMAIN_EVENT_ID_PMWAKEUP = 11
  5720. VIR_DOMAIN_EVENT_ID_PMSUSPEND = 12
  5721. VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE = 13
  5722. VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK = 14
  5723. VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED = 15
  5724. VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2 = 16
  5725. VIR_DOMAIN_EVENT_ID_TUNABLE = 17
  5726. VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE = 18
  5727.  
  5728. # virDomainEventIOErrorAction
  5729. VIR_DOMAIN_EVENT_IO_ERROR_NONE = 0
  5730. VIR_DOMAIN_EVENT_IO_ERROR_PAUSE = 1
  5731. VIR_DOMAIN_EVENT_IO_ERROR_REPORT = 2
  5732.  
  5733. # virDomainEventPMSuspendedDetailType
  5734. VIR_DOMAIN_EVENT_PMSUSPENDED_MEMORY = 0
  5735. VIR_DOMAIN_EVENT_PMSUSPENDED_DISK = 1
  5736.  
  5737. # virDomainEventResumedDetailType
  5738. VIR_DOMAIN_EVENT_RESUMED_UNPAUSED = 0
  5739. VIR_DOMAIN_EVENT_RESUMED_MIGRATED = 1
  5740. VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT = 2
  5741.  
  5742. # virDomainEventShutdownDetailType
  5743. VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED = 0
  5744.  
  5745. # virDomainEventStartedDetailType
  5746. VIR_DOMAIN_EVENT_STARTED_BOOTED = 0
  5747. VIR_DOMAIN_EVENT_STARTED_MIGRATED = 1
  5748. VIR_DOMAIN_EVENT_STARTED_RESTORED = 2
  5749. VIR_DOMAIN_EVENT_STARTED_FROM_SNAPSHOT = 3
  5750. VIR_DOMAIN_EVENT_STARTED_WAKEUP = 4
  5751.  
  5752. # virDomainEventStoppedDetailType
  5753. VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN = 0
  5754. VIR_DOMAIN_EVENT_STOPPED_DESTROYED = 1
  5755. VIR_DOMAIN_EVENT_STOPPED_CRASHED = 2
  5756. VIR_DOMAIN_EVENT_STOPPED_MIGRATED = 3
  5757. VIR_DOMAIN_EVENT_STOPPED_SAVED = 4
  5758. VIR_DOMAIN_EVENT_STOPPED_FAILED = 5
  5759. VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT = 6
  5760.  
  5761. # virDomainEventSuspendedDetailType
  5762. VIR_DOMAIN_EVENT_SUSPENDED_PAUSED = 0
  5763. VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED = 1
  5764. VIR_DOMAIN_EVENT_SUSPENDED_IOERROR = 2
  5765. VIR_DOMAIN_EVENT_SUSPENDED_WATCHDOG = 3
  5766. VIR_DOMAIN_EVENT_SUSPENDED_RESTORED = 4
  5767. VIR_DOMAIN_EVENT_SUSPENDED_FROM_SNAPSHOT = 5
  5768. VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR = 6
  5769.  
  5770. # virDomainEventTrayChangeReason
  5771. VIR_DOMAIN_EVENT_TRAY_CHANGE_OPEN = 0
  5772. VIR_DOMAIN_EVENT_TRAY_CHANGE_CLOSE = 1
  5773.  
  5774. # virDomainEventType
  5775. VIR_DOMAIN_EVENT_DEFINED = 0
  5776. VIR_DOMAIN_EVENT_UNDEFINED = 1
  5777. VIR_DOMAIN_EVENT_STARTED = 2
  5778. VIR_DOMAIN_EVENT_SUSPENDED = 3
  5779. VIR_DOMAIN_EVENT_RESUMED = 4
  5780. VIR_DOMAIN_EVENT_STOPPED = 5
  5781. VIR_DOMAIN_EVENT_SHUTDOWN = 6
  5782. VIR_DOMAIN_EVENT_PMSUSPENDED = 7
  5783. VIR_DOMAIN_EVENT_CRASHED = 8
  5784.  
  5785. # virDomainEventUndefinedDetailType
  5786. VIR_DOMAIN_EVENT_UNDEFINED_REMOVED = 0
  5787.  
  5788. # virDomainEventWatchdogAction
  5789. VIR_DOMAIN_EVENT_WATCHDOG_NONE = 0
  5790. VIR_DOMAIN_EVENT_WATCHDOG_PAUSE = 1
  5791. VIR_DOMAIN_EVENT_WATCHDOG_RESET = 2
  5792. VIR_DOMAIN_EVENT_WATCHDOG_POWEROFF = 3
  5793. VIR_DOMAIN_EVENT_WATCHDOG_SHUTDOWN = 4
  5794. VIR_DOMAIN_EVENT_WATCHDOG_DEBUG = 5
  5795.  
  5796. # virDomainGetJobStatsFlags
  5797. VIR_DOMAIN_JOB_STATS_COMPLETED = 1
  5798.  
  5799. # virDomainJobType
  5800. VIR_DOMAIN_JOB_NONE = 0
  5801. VIR_DOMAIN_JOB_BOUNDED = 1
  5802. VIR_DOMAIN_JOB_UNBOUNDED = 2
  5803. VIR_DOMAIN_JOB_COMPLETED = 3
  5804. VIR_DOMAIN_JOB_FAILED = 4
  5805. VIR_DOMAIN_JOB_CANCELLED = 5
  5806.  
  5807. # virDomainMemoryFlags
  5808. VIR_MEMORY_VIRTUAL = 1
  5809. VIR_MEMORY_PHYSICAL = 2
  5810.  
  5811. # virDomainMemoryModFlags
  5812. VIR_DOMAIN_MEM_CURRENT = 0
  5813. VIR_DOMAIN_MEM_LIVE = 1
  5814. VIR_DOMAIN_MEM_CONFIG = 2
  5815. VIR_DOMAIN_MEM_MAXIMUM = 4
  5816.  
  5817. # virDomainMemoryStatTags
  5818. VIR_DOMAIN_MEMORY_STAT_SWAP_IN = 0
  5819. VIR_DOMAIN_MEMORY_STAT_SWAP_OUT = 1
  5820. VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT = 2
  5821. VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT = 3
  5822. VIR_DOMAIN_MEMORY_STAT_UNUSED = 4
  5823. VIR_DOMAIN_MEMORY_STAT_AVAILABLE = 5
  5824. VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON = 6
  5825. VIR_DOMAIN_MEMORY_STAT_RSS = 7
  5826. VIR_DOMAIN_MEMORY_STAT_LAST = 8
  5827. VIR_DOMAIN_MEMORY_STAT_NR = 8
  5828.  
  5829. # virDomainMetadataType
  5830. VIR_DOMAIN_METADATA_DESCRIPTION = 0
  5831. VIR_DOMAIN_METADATA_TITLE = 1
  5832. VIR_DOMAIN_METADATA_ELEMENT = 2
  5833.  
  5834. # virDomainMigrateFlags
  5835. VIR_MIGRATE_LIVE = 1
  5836. VIR_MIGRATE_PEER2PEER = 2
  5837. VIR_MIGRATE_TUNNELLED = 4
  5838. VIR_MIGRATE_PERSIST_DEST = 8
  5839. VIR_MIGRATE_UNDEFINE_SOURCE = 16
  5840. VIR_MIGRATE_PAUSED = 32
  5841. VIR_MIGRATE_NON_SHARED_DISK = 64
  5842. VIR_MIGRATE_NON_SHARED_INC = 128
  5843. VIR_MIGRATE_CHANGE_PROTECTION = 256
  5844. VIR_MIGRATE_UNSAFE = 512
  5845. VIR_MIGRATE_OFFLINE = 1024
  5846. VIR_MIGRATE_COMPRESSED = 2048
  5847. VIR_MIGRATE_ABORT_ON_ERROR = 4096
  5848. VIR_MIGRATE_AUTO_CONVERGE = 8192
  5849. VIR_MIGRATE_RDMA_PIN_ALL = 16384
  5850.  
  5851. # virDomainModificationImpact
  5852. VIR_DOMAIN_AFFECT_CURRENT = 0
  5853. VIR_DOMAIN_AFFECT_LIVE = 1
  5854. VIR_DOMAIN_AFFECT_CONFIG = 2
  5855.  
  5856. # virDomainNostateReason
  5857. VIR_DOMAIN_NOSTATE_UNKNOWN = 0
  5858.  
  5859. # virDomainNumatuneMemMode
  5860. VIR_DOMAIN_NUMATUNE_MEM_STRICT = 0
  5861. VIR_DOMAIN_NUMATUNE_MEM_PREFERRED = 1
  5862. VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE = 2
  5863.  
  5864. # virDomainOpenGraphicsFlags
  5865. VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH = 1
  5866.  
  5867. # virDomainPMSuspendedDiskReason
  5868. VIR_DOMAIN_PMSUSPENDED_DISK_UNKNOWN = 0
  5869.  
  5870. # virDomainPMSuspendedReason
  5871. VIR_DOMAIN_PMSUSPENDED_UNKNOWN = 0
  5872.  
  5873. # virDomainPausedReason
  5874. VIR_DOMAIN_PAUSED_UNKNOWN = 0
  5875. VIR_DOMAIN_PAUSED_USER = 1
  5876. VIR_DOMAIN_PAUSED_MIGRATION = 2
  5877. VIR_DOMAIN_PAUSED_SAVE = 3
  5878. VIR_DOMAIN_PAUSED_DUMP = 4
  5879. VIR_DOMAIN_PAUSED_IOERROR = 5
  5880. VIR_DOMAIN_PAUSED_WATCHDOG = 6
  5881. VIR_DOMAIN_PAUSED_FROM_SNAPSHOT = 7
  5882. VIR_DOMAIN_PAUSED_SHUTTING_DOWN = 8
  5883. VIR_DOMAIN_PAUSED_SNAPSHOT = 9
  5884. VIR_DOMAIN_PAUSED_CRASHED = 10
  5885.  
  5886. # virDomainProcessSignal
  5887. VIR_DOMAIN_PROCESS_SIGNAL_NOP = 0
  5888. VIR_DOMAIN_PROCESS_SIGNAL_HUP = 1
  5889. VIR_DOMAIN_PROCESS_SIGNAL_INT = 2
  5890. VIR_DOMAIN_PROCESS_SIGNAL_QUIT = 3
  5891. VIR_DOMAIN_PROCESS_SIGNAL_ILL = 4
  5892. VIR_DOMAIN_PROCESS_SIGNAL_TRAP = 5
  5893. VIR_DOMAIN_PROCESS_SIGNAL_ABRT = 6
  5894. VIR_DOMAIN_PROCESS_SIGNAL_BUS = 7
  5895. VIR_DOMAIN_PROCESS_SIGNAL_FPE = 8
  5896. VIR_DOMAIN_PROCESS_SIGNAL_KILL = 9
  5897. VIR_DOMAIN_PROCESS_SIGNAL_USR1 = 10
  5898. VIR_DOMAIN_PROCESS_SIGNAL_SEGV = 11
  5899. VIR_DOMAIN_PROCESS_SIGNAL_USR2 = 12
  5900. VIR_DOMAIN_PROCESS_SIGNAL_PIPE = 13
  5901. VIR_DOMAIN_PROCESS_SIGNAL_ALRM = 14
  5902. VIR_DOMAIN_PROCESS_SIGNAL_TERM = 15
  5903. VIR_DOMAIN_PROCESS_SIGNAL_STKFLT = 16
  5904. VIR_DOMAIN_PROCESS_SIGNAL_CHLD = 17
  5905. VIR_DOMAIN_PROCESS_SIGNAL_CONT = 18
  5906. VIR_DOMAIN_PROCESS_SIGNAL_STOP = 19
  5907. VIR_DOMAIN_PROCESS_SIGNAL_TSTP = 20
  5908. VIR_DOMAIN_PROCESS_SIGNAL_TTIN = 21
  5909. VIR_DOMAIN_PROCESS_SIGNAL_TTOU = 22
  5910. VIR_DOMAIN_PROCESS_SIGNAL_URG = 23
  5911. VIR_DOMAIN_PROCESS_SIGNAL_XCPU = 24
  5912. VIR_DOMAIN_PROCESS_SIGNAL_XFSZ = 25
  5913. VIR_DOMAIN_PROCESS_SIGNAL_VTALRM = 26
  5914. VIR_DOMAIN_PROCESS_SIGNAL_PROF = 27
  5915. VIR_DOMAIN_PROCESS_SIGNAL_WINCH = 28
  5916. VIR_DOMAIN_PROCESS_SIGNAL_POLL = 29
  5917. VIR_DOMAIN_PROCESS_SIGNAL_PWR = 30
  5918. VIR_DOMAIN_PROCESS_SIGNAL_SYS = 31
  5919. VIR_DOMAIN_PROCESS_SIGNAL_RT0 = 32
  5920. VIR_DOMAIN_PROCESS_SIGNAL_RT1 = 33
  5921. VIR_DOMAIN_PROCESS_SIGNAL_RT2 = 34
  5922. VIR_DOMAIN_PROCESS_SIGNAL_RT3 = 35
  5923. VIR_DOMAIN_PROCESS_SIGNAL_RT4 = 36
  5924. VIR_DOMAIN_PROCESS_SIGNAL_RT5 = 37
  5925. VIR_DOMAIN_PROCESS_SIGNAL_RT6 = 38
  5926. VIR_DOMAIN_PROCESS_SIGNAL_RT7 = 39
  5927. VIR_DOMAIN_PROCESS_SIGNAL_RT8 = 40
  5928. VIR_DOMAIN_PROCESS_SIGNAL_RT9 = 41
  5929. VIR_DOMAIN_PROCESS_SIGNAL_RT10 = 42
  5930. VIR_DOMAIN_PROCESS_SIGNAL_RT11 = 43
  5931. VIR_DOMAIN_PROCESS_SIGNAL_RT12 = 44
  5932. VIR_DOMAIN_PROCESS_SIGNAL_RT13 = 45
  5933. VIR_DOMAIN_PROCESS_SIGNAL_RT14 = 46
  5934. VIR_DOMAIN_PROCESS_SIGNAL_RT15 = 47
  5935. VIR_DOMAIN_PROCESS_SIGNAL_RT16 = 48
  5936. VIR_DOMAIN_PROCESS_SIGNAL_RT17 = 49
  5937. VIR_DOMAIN_PROCESS_SIGNAL_RT18 = 50
  5938. VIR_DOMAIN_PROCESS_SIGNAL_RT19 = 51
  5939. VIR_DOMAIN_PROCESS_SIGNAL_RT20 = 52
  5940. VIR_DOMAIN_PROCESS_SIGNAL_RT21 = 53
  5941. VIR_DOMAIN_PROCESS_SIGNAL_RT22 = 54
  5942. VIR_DOMAIN_PROCESS_SIGNAL_RT23 = 55
  5943. VIR_DOMAIN_PROCESS_SIGNAL_RT24 = 56
  5944. VIR_DOMAIN_PROCESS_SIGNAL_RT25 = 57
  5945. VIR_DOMAIN_PROCESS_SIGNAL_RT26 = 58
  5946. VIR_DOMAIN_PROCESS_SIGNAL_RT27 = 59
  5947. VIR_DOMAIN_PROCESS_SIGNAL_RT28 = 60
  5948. VIR_DOMAIN_PROCESS_SIGNAL_RT29 = 61
  5949. VIR_DOMAIN_PROCESS_SIGNAL_RT30 = 62
  5950. VIR_DOMAIN_PROCESS_SIGNAL_RT31 = 63
  5951. VIR_DOMAIN_PROCESS_SIGNAL_RT32 = 64
  5952.  
  5953. # virDomainRebootFlagValues
  5954. VIR_DOMAIN_REBOOT_DEFAULT = 0
  5955. VIR_DOMAIN_REBOOT_ACPI_POWER_BTN = 1
  5956. VIR_DOMAIN_REBOOT_GUEST_AGENT = 2
  5957. VIR_DOMAIN_REBOOT_INITCTL = 4
  5958. VIR_DOMAIN_REBOOT_SIGNAL = 8
  5959. VIR_DOMAIN_REBOOT_PARAVIRT = 16
  5960.  
  5961. # virDomainRunningReason
  5962. VIR_DOMAIN_RUNNING_UNKNOWN = 0
  5963. VIR_DOMAIN_RUNNING_BOOTED = 1
  5964. VIR_DOMAIN_RUNNING_MIGRATED = 2
  5965. VIR_DOMAIN_RUNNING_RESTORED = 3
  5966. VIR_DOMAIN_RUNNING_FROM_SNAPSHOT = 4
  5967. VIR_DOMAIN_RUNNING_UNPAUSED = 5
  5968. VIR_DOMAIN_RUNNING_MIGRATION_CANCELED = 6
  5969. VIR_DOMAIN_RUNNING_SAVE_CANCELED = 7
  5970. VIR_DOMAIN_RUNNING_WAKEUP = 8
  5971. VIR_DOMAIN_RUNNING_CRASHED = 9
  5972.  
  5973. # virDomainSaveRestoreFlags
  5974. VIR_DOMAIN_SAVE_BYPASS_CACHE = 1
  5975. VIR_DOMAIN_SAVE_RUNNING = 2
  5976. VIR_DOMAIN_SAVE_PAUSED = 4
  5977.  
  5978. # virDomainSetTimeFlags
  5979. VIR_DOMAIN_TIME_SYNC = 1
  5980.  
  5981. # virDomainShutdownFlagValues
  5982. VIR_DOMAIN_SHUTDOWN_DEFAULT = 0
  5983. VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN = 1
  5984. VIR_DOMAIN_SHUTDOWN_GUEST_AGENT = 2
  5985. VIR_DOMAIN_SHUTDOWN_INITCTL = 4
  5986. VIR_DOMAIN_SHUTDOWN_SIGNAL = 8
  5987. VIR_DOMAIN_SHUTDOWN_PARAVIRT = 16
  5988.  
  5989. # virDomainShutdownReason
  5990. VIR_DOMAIN_SHUTDOWN_UNKNOWN = 0
  5991. VIR_DOMAIN_SHUTDOWN_USER = 1
  5992.  
  5993. # virDomainShutoffReason
  5994. VIR_DOMAIN_SHUTOFF_UNKNOWN = 0
  5995. VIR_DOMAIN_SHUTOFF_SHUTDOWN = 1
  5996. VIR_DOMAIN_SHUTOFF_DESTROYED = 2
  5997. VIR_DOMAIN_SHUTOFF_CRASHED = 3
  5998. VIR_DOMAIN_SHUTOFF_MIGRATED = 4
  5999. VIR_DOMAIN_SHUTOFF_SAVED = 5
  6000. VIR_DOMAIN_SHUTOFF_FAILED = 6
  6001. VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT = 7
  6002.  
  6003. # virDomainSnapshotCreateFlags
  6004. VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE = 1
  6005. VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT = 2
  6006. VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA = 4
  6007. VIR_DOMAIN_SNAPSHOT_CREATE_HALT = 8
  6008. VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY = 16
  6009. VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT = 32
  6010. VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE = 64
  6011. VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC = 128
  6012. VIR_DOMAIN_SNAPSHOT_CREATE_LIVE = 256
  6013.  
  6014. # virDomainSnapshotDeleteFlags
  6015. VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN = 1
  6016. VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY = 2
  6017. VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY = 4
  6018.  
  6019. # virDomainSnapshotListFlags
  6020. VIR_DOMAIN_SNAPSHOT_LIST_ROOTS = 1
  6021. VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS = 1
  6022. VIR_DOMAIN_SNAPSHOT_LIST_METADATA = 2
  6023. VIR_DOMAIN_SNAPSHOT_LIST_LEAVES = 4
  6024. VIR_DOMAIN_SNAPSHOT_LIST_NO_LEAVES = 8
  6025. VIR_DOMAIN_SNAPSHOT_LIST_NO_METADATA = 16
  6026. VIR_DOMAIN_SNAPSHOT_LIST_INACTIVE = 32
  6027. VIR_DOMAIN_SNAPSHOT_LIST_ACTIVE = 64
  6028. VIR_DOMAIN_SNAPSHOT_LIST_DISK_ONLY = 128
  6029. VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL = 256
  6030. VIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL = 512
  6031.  
  6032. # virDomainSnapshotRevertFlags
  6033. VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING = 1
  6034. VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED = 2
  6035. VIR_DOMAIN_SNAPSHOT_REVERT_FORCE = 4
  6036.  
  6037. # virDomainState
  6038. VIR_DOMAIN_NOSTATE = 0
  6039. VIR_DOMAIN_RUNNING = 1
  6040. VIR_DOMAIN_BLOCKED = 2
  6041. VIR_DOMAIN_PAUSED = 3
  6042. VIR_DOMAIN_SHUTDOWN = 4
  6043. VIR_DOMAIN_SHUTOFF = 5
  6044. VIR_DOMAIN_CRASHED = 6
  6045. VIR_DOMAIN_PMSUSPENDED = 7
  6046.  
  6047. # virDomainStatsTypes
  6048. VIR_DOMAIN_STATS_STATE = 1
  6049. VIR_DOMAIN_STATS_CPU_TOTAL = 2
  6050. VIR_DOMAIN_STATS_BALLOON = 4
  6051. VIR_DOMAIN_STATS_VCPU = 8
  6052. VIR_DOMAIN_STATS_INTERFACE = 16
  6053. VIR_DOMAIN_STATS_BLOCK = 32
  6054.  
  6055. # virDomainUndefineFlagsValues
  6056. VIR_DOMAIN_UNDEFINE_MANAGED_SAVE = 1
  6057. VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA = 2
  6058. VIR_DOMAIN_UNDEFINE_NVRAM = 4
  6059.  
  6060. # virDomainVcpuFlags
  6061. VIR_DOMAIN_VCPU_CURRENT = 0
  6062. VIR_DOMAIN_VCPU_LIVE = 1
  6063. VIR_DOMAIN_VCPU_CONFIG = 2
  6064. VIR_DOMAIN_VCPU_MAXIMUM = 4
  6065. VIR_DOMAIN_VCPU_GUEST = 8
  6066.  
  6067. # virDomainXMLFlags
  6068. VIR_DOMAIN_XML_SECURE = 1
  6069. VIR_DOMAIN_XML_INACTIVE = 2
  6070. VIR_DOMAIN_XML_UPDATE_CPU = 4
  6071. VIR_DOMAIN_XML_MIGRATABLE = 8
  6072.  
  6073. # virErrorDomain
  6074. VIR_FROM_NONE = 0
  6075. VIR_FROM_XEN = 1
  6076. VIR_FROM_XEND = 2
  6077. VIR_FROM_XENSTORE = 3
  6078. VIR_FROM_SEXPR = 4
  6079. VIR_FROM_XML = 5
  6080. VIR_FROM_DOM = 6
  6081. VIR_FROM_RPC = 7
  6082. VIR_FROM_PROXY = 8
  6083. VIR_FROM_CONF = 9
  6084. VIR_FROM_QEMU = 10
  6085. VIR_FROM_NET = 11
  6086. VIR_FROM_TEST = 12
  6087. VIR_FROM_REMOTE = 13
  6088. VIR_FROM_OPENVZ = 14
  6089. VIR_FROM_XENXM = 15
  6090. VIR_FROM_STATS_LINUX = 16
  6091. VIR_FROM_LXC = 17
  6092. VIR_FROM_STORAGE = 18
  6093. VIR_FROM_NETWORK = 19
  6094. VIR_FROM_DOMAIN = 20
  6095. VIR_FROM_UML = 21
  6096. VIR_FROM_NODEDEV = 22
  6097. VIR_FROM_XEN_INOTIFY = 23
  6098. VIR_FROM_SECURITY = 24
  6099. VIR_FROM_VBOX = 25
  6100. VIR_FROM_INTERFACE = 26
  6101. VIR_FROM_ONE = 27
  6102. VIR_FROM_ESX = 28
  6103. VIR_FROM_PHYP = 29
  6104. VIR_FROM_SECRET = 30
  6105. VIR_FROM_CPU = 31
  6106. VIR_FROM_XENAPI = 32
  6107. VIR_FROM_NWFILTER = 33
  6108. VIR_FROM_HOOK = 34
  6109. VIR_FROM_DOMAIN_SNAPSHOT = 35
  6110. VIR_FROM_AUDIT = 36
  6111. VIR_FROM_SYSINFO = 37
  6112. VIR_FROM_STREAMS = 38
  6113. VIR_FROM_VMWARE = 39
  6114. VIR_FROM_EVENT = 40
  6115. VIR_FROM_LIBXL = 41
  6116. VIR_FROM_LOCKING = 42
  6117. VIR_FROM_HYPERV = 43
  6118. VIR_FROM_CAPABILITIES = 44
  6119. VIR_FROM_URI = 45
  6120. VIR_FROM_AUTH = 46
  6121. VIR_FROM_DBUS = 47
  6122. VIR_FROM_PARALLELS = 48
  6123. VIR_FROM_DEVICE = 49
  6124. VIR_FROM_SSH = 50
  6125. VIR_FROM_LOCKSPACE = 51
  6126. VIR_FROM_INITCTL = 52
  6127. VIR_FROM_IDENTITY = 53
  6128. VIR_FROM_CGROUP = 54
  6129. VIR_FROM_ACCESS = 55
  6130. VIR_FROM_SYSTEMD = 56
  6131. VIR_FROM_BHYVE = 57
  6132. VIR_FROM_CRYPTO = 58
  6133. VIR_FROM_FIREWALL = 59
  6134.  
  6135. # virErrorLevel
  6136. VIR_ERR_NONE = 0
  6137. VIR_ERR_WARNING = 1
  6138. VIR_ERR_ERROR = 2
  6139.  
  6140. # virErrorNumber
  6141. VIR_ERR_OK = 0
  6142. VIR_ERR_INTERNAL_ERROR = 1
  6143. VIR_ERR_NO_MEMORY = 2
  6144. VIR_ERR_NO_SUPPORT = 3
  6145. VIR_ERR_UNKNOWN_HOST = 4
  6146. VIR_ERR_NO_CONNECT = 5
  6147. VIR_ERR_INVALID_CONN = 6
  6148. VIR_ERR_INVALID_DOMAIN = 7
  6149. VIR_ERR_INVALID_ARG = 8
  6150. VIR_ERR_OPERATION_FAILED = 9
  6151. VIR_ERR_GET_FAILED = 10
  6152. VIR_ERR_POST_FAILED = 11
  6153. VIR_ERR_HTTP_ERROR = 12
  6154. VIR_ERR_SEXPR_SERIAL = 13
  6155. VIR_ERR_NO_XEN = 14
  6156. VIR_ERR_XEN_CALL = 15
  6157. VIR_ERR_OS_TYPE = 16
  6158. VIR_ERR_NO_KERNEL = 17
  6159. VIR_ERR_NO_ROOT = 18
  6160. VIR_ERR_NO_SOURCE = 19
  6161. VIR_ERR_NO_TARGET = 20
  6162. VIR_ERR_NO_NAME = 21
  6163. VIR_ERR_NO_OS = 22
  6164. VIR_ERR_NO_DEVICE = 23
  6165. VIR_ERR_NO_XENSTORE = 24
  6166. VIR_ERR_DRIVER_FULL = 25
  6167. VIR_ERR_CALL_FAILED = 26
  6168. VIR_ERR_XML_ERROR = 27
  6169. VIR_ERR_DOM_EXIST = 28
  6170. VIR_ERR_OPERATION_DENIED = 29
  6171. VIR_ERR_OPEN_FAILED = 30
  6172. VIR_ERR_READ_FAILED = 31
  6173. VIR_ERR_PARSE_FAILED = 32
  6174. VIR_ERR_CONF_SYNTAX = 33
  6175. VIR_ERR_WRITE_FAILED = 34
  6176. VIR_ERR_XML_DETAIL = 35
  6177. VIR_ERR_INVALID_NETWORK = 36
  6178. VIR_ERR_NETWORK_EXIST = 37
  6179. VIR_ERR_SYSTEM_ERROR = 38
  6180. VIR_ERR_RPC = 39
  6181. VIR_ERR_GNUTLS_ERROR = 40
  6182. VIR_WAR_NO_NETWORK = 41
  6183. VIR_ERR_NO_DOMAIN = 42
  6184. VIR_ERR_NO_NETWORK = 43
  6185. VIR_ERR_INVALID_MAC = 44
  6186. VIR_ERR_AUTH_FAILED = 45
  6187. VIR_ERR_INVALID_STORAGE_POOL = 46
  6188. VIR_ERR_INVALID_STORAGE_VOL = 47
  6189. VIR_WAR_NO_STORAGE = 48
  6190. VIR_ERR_NO_STORAGE_POOL = 49
  6191. VIR_ERR_NO_STORAGE_VOL = 50
  6192. VIR_WAR_NO_NODE = 51
  6193. VIR_ERR_INVALID_NODE_DEVICE = 52
  6194. VIR_ERR_NO_NODE_DEVICE = 53
  6195. VIR_ERR_NO_SECURITY_MODEL = 54
  6196. VIR_ERR_OPERATION_INVALID = 55
  6197. VIR_WAR_NO_INTERFACE = 56
  6198. VIR_ERR_NO_INTERFACE = 57
  6199. VIR_ERR_INVALID_INTERFACE = 58
  6200. VIR_ERR_MULTIPLE_INTERFACES = 59
  6201. VIR_WAR_NO_NWFILTER = 60
  6202. VIR_ERR_INVALID_NWFILTER = 61
  6203. VIR_ERR_NO_NWFILTER = 62
  6204. VIR_ERR_BUILD_FIREWALL = 63
  6205. VIR_WAR_NO_SECRET = 64
  6206. VIR_ERR_INVALID_SECRET = 65
  6207. VIR_ERR_NO_SECRET = 66
  6208. VIR_ERR_CONFIG_UNSUPPORTED = 67
  6209. VIR_ERR_OPERATION_TIMEOUT = 68
  6210. VIR_ERR_MIGRATE_PERSIST_FAILED = 69
  6211. VIR_ERR_HOOK_SCRIPT_FAILED = 70
  6212. VIR_ERR_INVALID_DOMAIN_SNAPSHOT = 71
  6213. VIR_ERR_NO_DOMAIN_SNAPSHOT = 72
  6214. VIR_ERR_INVALID_STREAM = 73
  6215. VIR_ERR_ARGUMENT_UNSUPPORTED = 74
  6216. VIR_ERR_STORAGE_PROBE_FAILED = 75
  6217. VIR_ERR_STORAGE_POOL_BUILT = 76
  6218. VIR_ERR_SNAPSHOT_REVERT_RISKY = 77
  6219. VIR_ERR_OPERATION_ABORTED = 78
  6220. VIR_ERR_AUTH_CANCELLED = 79
  6221. VIR_ERR_NO_DOMAIN_METADATA = 80
  6222. VIR_ERR_MIGRATE_UNSAFE = 81
  6223. VIR_ERR_OVERFLOW = 82
  6224. VIR_ERR_BLOCK_COPY_ACTIVE = 83
  6225. VIR_ERR_OPERATION_UNSUPPORTED = 84
  6226. VIR_ERR_SSH = 85
  6227. VIR_ERR_AGENT_UNRESPONSIVE = 86
  6228. VIR_ERR_RESOURCE_BUSY = 87
  6229. VIR_ERR_ACCESS_DENIED = 88
  6230. VIR_ERR_DBUS_SERVICE = 89
  6231. VIR_ERR_STORAGE_VOL_EXIST = 90
  6232. VIR_ERR_CPU_INCOMPATIBLE = 91
  6233.  
  6234. # virEventHandleType
  6235. VIR_EVENT_HANDLE_READABLE = 1
  6236. VIR_EVENT_HANDLE_WRITABLE = 2
  6237. VIR_EVENT_HANDLE_ERROR = 4
  6238. VIR_EVENT_HANDLE_HANGUP = 8
  6239.  
  6240. # virIPAddrType
  6241. VIR_IP_ADDR_TYPE_IPV4 = 0
  6242. VIR_IP_ADDR_TYPE_IPV6 = 1
  6243.  
  6244. # virInterfaceXMLFlags
  6245. VIR_INTERFACE_XML_INACTIVE = 1
  6246.  
  6247. # virKeycodeSet
  6248. VIR_KEYCODE_SET_LINUX = 0
  6249. VIR_KEYCODE_SET_XT = 1
  6250. VIR_KEYCODE_SET_ATSET1 = 2
  6251. VIR_KEYCODE_SET_ATSET2 = 3
  6252. VIR_KEYCODE_SET_ATSET3 = 4
  6253. VIR_KEYCODE_SET_OSX = 5
  6254. VIR_KEYCODE_SET_XT_KBD = 6
  6255. VIR_KEYCODE_SET_USB = 7
  6256. VIR_KEYCODE_SET_WIN32 = 8
  6257. VIR_KEYCODE_SET_RFB = 9
  6258.  
  6259. # virMemoryParameterType
  6260. VIR_DOMAIN_MEMORY_PARAM_INT = 1
  6261. VIR_DOMAIN_MEMORY_PARAM_UINT = 2
  6262. VIR_DOMAIN_MEMORY_PARAM_LLONG = 3
  6263. VIR_DOMAIN_MEMORY_PARAM_ULLONG = 4
  6264. VIR_DOMAIN_MEMORY_PARAM_DOUBLE = 5
  6265. VIR_DOMAIN_MEMORY_PARAM_BOOLEAN = 6
  6266.  
  6267. # virNetworkEventID
  6268. VIR_NETWORK_EVENT_ID_LIFECYCLE = 0
  6269.  
  6270. # virNetworkEventLifecycleType
  6271. VIR_NETWORK_EVENT_DEFINED = 0
  6272. VIR_NETWORK_EVENT_UNDEFINED = 1
  6273. VIR_NETWORK_EVENT_STARTED = 2
  6274. VIR_NETWORK_EVENT_STOPPED = 3
  6275.  
  6276. # virNetworkUpdateCommand
  6277. VIR_NETWORK_UPDATE_COMMAND_NONE = 0
  6278. VIR_NETWORK_UPDATE_COMMAND_MODIFY = 1
  6279. VIR_NETWORK_UPDATE_COMMAND_DELETE = 2
  6280. VIR_NETWORK_UPDATE_COMMAND_ADD_LAST = 3
  6281. VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST = 4
  6282.  
  6283. # virNetworkUpdateFlags
  6284. VIR_NETWORK_UPDATE_AFFECT_CURRENT = 0
  6285. VIR_NETWORK_UPDATE_AFFECT_LIVE = 1
  6286. VIR_NETWORK_UPDATE_AFFECT_CONFIG = 2
  6287.  
  6288. # virNetworkUpdateSection
  6289. VIR_NETWORK_SECTION_NONE = 0
  6290. VIR_NETWORK_SECTION_BRIDGE = 1
  6291. VIR_NETWORK_SECTION_DOMAIN = 2
  6292. VIR_NETWORK_SECTION_IP = 3
  6293. VIR_NETWORK_SECTION_IP_DHCP_HOST = 4
  6294. VIR_NETWORK_SECTION_IP_DHCP_RANGE = 5
  6295. VIR_NETWORK_SECTION_FORWARD = 6
  6296. VIR_NETWORK_SECTION_FORWARD_INTERFACE = 7
  6297. VIR_NETWORK_SECTION_FORWARD_PF = 8
  6298. VIR_NETWORK_SECTION_PORTGROUP = 9
  6299. VIR_NETWORK_SECTION_DNS_HOST = 10
  6300. VIR_NETWORK_SECTION_DNS_TXT = 11
  6301. VIR_NETWORK_SECTION_DNS_SRV = 12
  6302.  
  6303. # virNetworkXMLFlags
  6304. VIR_NETWORK_XML_INACTIVE = 1
  6305.  
  6306. # virNodeGetCPUStatsAllCPUs
  6307. VIR_NODE_CPU_STATS_ALL_CPUS = -1
  6308.  
  6309. # virNodeGetMemoryStatsAllCells
  6310. VIR_NODE_MEMORY_STATS_ALL_CELLS = -1
  6311.  
  6312. # virNodeSuspendTarget
  6313. VIR_NODE_SUSPEND_TARGET_MEM = 0
  6314. VIR_NODE_SUSPEND_TARGET_DISK = 1
  6315. VIR_NODE_SUSPEND_TARGET_HYBRID = 2
  6316.  
  6317. # virSchedParameterType
  6318. VIR_DOMAIN_SCHED_FIELD_INT = 1
  6319. VIR_DOMAIN_SCHED_FIELD_UINT = 2
  6320. VIR_DOMAIN_SCHED_FIELD_LLONG = 3
  6321. VIR_DOMAIN_SCHED_FIELD_ULLONG = 4
  6322. VIR_DOMAIN_SCHED_FIELD_DOUBLE = 5
  6323. VIR_DOMAIN_SCHED_FIELD_BOOLEAN = 6
  6324.  
  6325. # virSecretUsageType
  6326. VIR_SECRET_USAGE_TYPE_NONE = 0
  6327. VIR_SECRET_USAGE_TYPE_VOLUME = 1
  6328. VIR_SECRET_USAGE_TYPE_CEPH = 2
  6329. VIR_SECRET_USAGE_TYPE_ISCSI = 3
  6330.  
  6331. # virStoragePoolBuildFlags
  6332. VIR_STORAGE_POOL_BUILD_NEW = 0
  6333. VIR_STORAGE_POOL_BUILD_REPAIR = 1
  6334. VIR_STORAGE_POOL_BUILD_RESIZE = 2
  6335. VIR_STORAGE_POOL_BUILD_NO_OVERWRITE = 4
  6336. VIR_STORAGE_POOL_BUILD_OVERWRITE = 8
  6337.  
  6338. # virStoragePoolDeleteFlags
  6339. VIR_STORAGE_POOL_DELETE_NORMAL = 0
  6340. VIR_STORAGE_POOL_DELETE_ZEROED = 1
  6341.  
  6342. # virStoragePoolState
  6343. VIR_STORAGE_POOL_INACTIVE = 0
  6344. VIR_STORAGE_POOL_BUILDING = 1
  6345. VIR_STORAGE_POOL_RUNNING = 2
  6346. VIR_STORAGE_POOL_DEGRADED = 3
  6347. VIR_STORAGE_POOL_INACCESSIBLE = 4
  6348.  
  6349. # virStorageVolCreateFlags
  6350. VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA = 1
  6351.  
  6352. # virStorageVolDeleteFlags
  6353. VIR_STORAGE_VOL_DELETE_NORMAL = 0
  6354. VIR_STORAGE_VOL_DELETE_ZEROED = 1
  6355.  
  6356. # virStorageVolResizeFlags
  6357. VIR_STORAGE_VOL_RESIZE_ALLOCATE = 1
  6358. VIR_STORAGE_VOL_RESIZE_DELTA = 2
  6359. VIR_STORAGE_VOL_RESIZE_SHRINK = 4
  6360.  
  6361. # virStorageVolType
  6362. VIR_STORAGE_VOL_FILE = 0
  6363. VIR_STORAGE_VOL_BLOCK = 1
  6364. VIR_STORAGE_VOL_DIR = 2
  6365. VIR_STORAGE_VOL_NETWORK = 3
  6366. VIR_STORAGE_VOL_NETDIR = 4
  6367.  
  6368. # virStorageVolWipeAlgorithm
  6369. VIR_STORAGE_VOL_WIPE_ALG_ZERO = 0
  6370. VIR_STORAGE_VOL_WIPE_ALG_NNSA = 1
  6371. VIR_STORAGE_VOL_WIPE_ALG_DOD = 2
  6372. VIR_STORAGE_VOL_WIPE_ALG_BSI = 3
  6373. VIR_STORAGE_VOL_WIPE_ALG_GUTMANN = 4
  6374. VIR_STORAGE_VOL_WIPE_ALG_SCHNEIER = 5
  6375. VIR_STORAGE_VOL_WIPE_ALG_PFITZNER7 = 6
  6376. VIR_STORAGE_VOL_WIPE_ALG_PFITZNER33 = 7
  6377. VIR_STORAGE_VOL_WIPE_ALG_RANDOM = 8
  6378.  
  6379. # virStorageXMLFlags
  6380. VIR_STORAGE_XML_INACTIVE = 1
  6381.  
  6382. # virStreamEventType
  6383. VIR_STREAM_EVENT_READABLE = 1
  6384. VIR_STREAM_EVENT_WRITABLE = 2
  6385. VIR_STREAM_EVENT_ERROR = 4
  6386. VIR_STREAM_EVENT_HANGUP = 8
  6387.  
  6388. # virStreamFlags
  6389. VIR_STREAM_NONBLOCK = 1
  6390.  
  6391. # virTypedParameterFlags
  6392. VIR_TYPED_PARAM_STRING_OKAY = 4
  6393.  
  6394. # virTypedParameterType
  6395. VIR_TYPED_PARAM_INT = 1
  6396. VIR_TYPED_PARAM_UINT = 2
  6397. VIR_TYPED_PARAM_LLONG = 3
  6398. VIR_TYPED_PARAM_ULLONG = 4
  6399. VIR_TYPED_PARAM_DOUBLE = 5
  6400. VIR_TYPED_PARAM_BOOLEAN = 6
  6401. VIR_TYPED_PARAM_STRING = 7
  6402.  
  6403. # virVcpuState
  6404. VIR_VCPU_OFFLINE = 0
  6405. VIR_VCPU_RUNNING = 1
  6406. VIR_VCPU_BLOCKED = 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement