Commit Graph

165 Commits

Author SHA1 Message Date
Daniel Veillard
54a4f8d44d add output on attach and detach success
* src/virsh.c: patch from Cole Robinson to add output on attach
  and detach success
daniel
2008-09-03 12:38:28 +00:00
Daniel Veillard
41ce15a586 Adds storage source element for pools
* src/storage_backend.h src/storage_backend_logical.c
src/storage_conf.c src/storage_conf.h src/virsh.c:
Applied patches from David Lively to add storage source
elements needed for storage pool
* docs/formatstorage.html docs/formatstorage.html.in: associated
documentation
Daniel
2008-09-02 14:15:42 +00:00
Daniel P. Berrange
39c9354c5c Add storage pool source discovery support (patch from David Lively) 2008-08-27 20:05:58 +00:00
Atsushi SAKAI
6fd4c30285 fix typos src/virsh.c from John Levon,
and 3 more files(src/domain_conf.c src/openvz_driver.c src/qemu_driver.c)
2008-08-15 01:41:49 +00:00
Atsushi SAKAI
43c7f972aa fix compilation for MinGW 2008-08-12 08:25:48 +00:00
Richard W.M. Jones
969fa847c1 'virsh edit' and related commands
* src/virsh.c: Implement 'virsh edit', 'virsh net-edit' and
	  'virsh pool-edit' commands.  These edit the XML for domains,
	  networks and storage pools respectively, and are the
	  equivalent of doing 'virsh dumpxml; vi foo.xml; virsh define'
	* src/Makefile.am, src/.cvsignore: Auto-generate the net-edit
	  and pool-edit commands.
	* docs/virsh.pod: Updated the documentation.
2008-08-01 14:30:41 +00:00
Jim Meyering
66f9bb5b95 virsh.c: more const-correctness fixes 2008-08-01 13:51:18 +00:00
Richard W.M. Jones
3f3345aa85 Const-correctness fixes in virsh.c
* src/virsh.c: Const-correctness.
2008-08-01 12:19:56 +00:00
Jim Meyering
2eb8ab2057 better diagnostic when failing to undefine a running domain via ID
* src/virsh.c (cmdUndefine): Tell user to shutdown and then use name or UUID.
* tests/undefine: New test.  Exercise virsh's undefine command.
* tests/Makefile.am (test_scripts): Add undefine.
2008-07-22 16:12:01 +00:00
Daniel Veillard
16b8942966 undefine command can't take an ID
* src/virsh.c: patch from Evgeniy Sokolov for the undefine command
  which can't take an id
Daniel
2008-07-17 11:49:15 +00:00
Daniel P. Berrange
a9d4944f8e Don't add trailing blanks in dominfo output 2008-05-29 14:56:12 +00:00
Richard W.M. Jones
5c9454aa6e Display autostart status in virsh dominfo command.
* src/virsh.c: Display autostart status in virsh dominfo
	command (Shigeki Sakamoto).
2008-05-27 09:41:25 +00:00
Richard W.M. Jones
1d8d4f86b6 Standardize use of header files, making internal.h primary.
* qemud/internal.h, qemud/qemud.h: Rename this file so it
	doesn't conflict with src/internal.h.
	* HACKING: Document how header files should be used.
	* qemud/Makefile.am: Add src/ directory to includes.
	* qemud/event.c, qemud/mdns.c, qemud/qemud.c, qemud/remote.c,
	qemud/remote_protocol.c, qemud/remote_protocol.h,
	qemud/remote_protocol.x, src/buf.c, src/libvirt.c,
	src/nodeinfo.c, src/qemu_conf.c, src/qemu_driver.c,
	src/stats_linux.c, src/storage_backend.c, src/storage_backend_fs.c,
	src/storage_backend_iscsi.c, src/storage_backend_logical.c,
	src/storage_conf.c, src/storage_driver.c, src/util.c,
	src/util.h, src/virsh.c, src/virterror.c, src/xend_internal.c,
	src/xml.c, tests/reconnect.c, tests/xmlrpctest.c,
	tests/qparamtest.c: Standardize	use of header files.
	* docs/*, po/*: Rebuild docs.
2008-05-23 08:24:41 +00:00
Daniel P. Berrange
e866e302f8 Fixed couple of memory leaks wrt to virXXXDestroy APIs, and clarify docs to match reality 2008-05-21 20:53:30 +00:00
Jim Meyering
c1ee35af3b start using c-ctype functions
Up to now, we've been avoiding ctype functions like isspace, isdigit,
etc.  because they are locale-dependent.  Now that we have the c-ctype
functions, we can start using *them*, to make the code more readable
with changes like these:

-        /* This may not work on EBCDIC. */
-        if ((*p >= 'a' && *p <= 'z') ||
-            (*p >= 'A' && *p <= 'Z') ||
-            (*p >= '0' && *p <= '9'))
+        if (c_isalnum(*p))

-    while ((*cur >= '0') && (*cur <= '9')) {
+    while (c_isdigit(*cur)) {

Also, some macros in conf.c used names that conflicted with
standard meaning of "BLANK" and "SPACE", so I've adjusted them
to be in line with the definition of e.g., isblank.
In addition, I've wrapped those statement macros with do {...} while (0),
so that we can't forget the ";" after a use.  There was one like that
already (fixed below).  The missing semicolon would mess up automatic
indenting.
* src/buf.c (virBufferURIEncodeString):
* src/conf.c (IS_EOL, SKIP_BLANKS_AND_EOL, SKIP_BLANKS)
(virConfParseLong, virConfParseValue, virConfParseName)
(virConfParseSeparator, virConfParseStatement, IS_BLANK, IS_CHAR)
(IS_DIGIT, IS_SPACE, SKIP_SPACES):
* src/nodeinfo.c:
* src/qemu_conf.c (qemudParseInterfaceXML):
* src/qemu_driver.c (qemudDomainBlockStats):
* src/sexpr.c:
* src/stats_linux.c:
* src/util.c (virParseNumber, virDiskNameToIndex):
* src/uuid.c (hextobin, virUUIDParse):
* src/virsh.c:
* src/xml.c (parseCpuNumber, virParseCpuSet):
2008-05-16 09:37:44 +00:00
Daniel P. Berrange
1d73398e8f Remove all use of strcmp, strncmp in favour of STREQ, STREQLEN, STRPREFIX 2008-05-14 19:51:24 +00:00
Jim Meyering
25534052bc Use gnulib's c-ctype.h, not <ctype.h>.
# Convert uses of isspace to c_isspace, isdigit to c_isdigit, etc.
re=$(man isspace|grep is.....,.is|sed 's/ -.*//' \
  |tr -s ', \n' \||sed 's/^|//;s/|$//')
git grep -l -E "$re"|grep -Ev 'Chan|gnulib' \
  |xargs perl -pi -e 's/\b('"$re"')\b/c_$1/g'
# Remove all uses of to_uchar
git grep -l to_uchar|xargs perl -pi -e 's/to_uchar\((.*?)\)/$1/g'
* src/util.h (to_uchar): Remove definition.
(TOLOWER): Remove definition.
(__virMacAddrCompare): Use c_tolower, not TOLOWER.
Globally:
  Where needed, change <ctype.h> to <c-ctype.h>.
  Remove unnecessary inclusion of <ctype.h>.
Ensure the global changes are never needed again:
* Makefile.maint (sc_avoid_ctype_macros): Prohibit use of ctype
macros.   Recommend c-ctype.h instead.
(sc_prohibit_c_ctype_without_use): New rule.
(sc_prohibit_ctype_h): New rule.  Disallow use of <ctype.h>.
2008-05-09 13:50:14 +00:00
Daniel P. Berrange
642b26fab2 Change virBuffer API to prevent common usage errors. Update all users of APIs 2008-04-28 15:14:59 +00:00
Jim Meyering
212472b813 avoid format-related warnings
* qemud/qemud.c (main): Fix a bogus format string reported as umarked.
* src/virsh.c (cmdVcpupin): Non-literal with no args.
2008-04-28 09:09:52 +00:00
Jim Meyering
225ba3f0af avoid problems with sign-extended "char" operand to is* functions
* src/util.h (to_uchar): Define function.
* src/nodeinfo.c (linuxNodeInfoCPUPopulate): Apply to_uchar to is* operand.
* src/qemu_driver.c (qemudExtractMonitorPath): Likewise.
* src/sexpr.c (_string2sexpr): Likewise.
* src/stats_linux.c (xenLinuxDomainDeviceID): Likewise.
* src/util.c (TOLOWER, __virMacAddrCompare, virParseMacAddr): Likewise.
* src/virsh.c (cmdVcpupin, vshCommandGetToken): Likewise.
2008-04-25 14:53:05 +00:00
Richard W.M. Jones
ba5411995b Remove unused uid field in virsh control structure.
* src/virsh.c: Remove unused uid field in virsh control structure.
2008-04-10 17:37:23 +00:00
Jim Meyering
5bf824ea10 convert TAB-based indentation in C sources to use only spaces
Done using this command (also includes .c.in and .h.in files):
for i in $(g ls-files|grep -E '\.[ch](\.in)?$'|grep -v gnulib); do
  expand -i $i > j && mv j $i;done
2008-04-10 16:54:54 +00:00
Jim Meyering
dc42a9d2de remove Vim and Emacs variable settings from C source files
Done with these commands:
git grep -l Local.variab|xargs \
  perl -0x3b -pi -e 's,\n+/\*\n \* vim:(.|\n)*,\n,'

git grep -l Local.variab|xargs \
  perl -0x3b -pi -e 's,\n+/\*\n \* Local variables:\n(.|\n)*,\n,'
2008-04-10 16:53:29 +00:00
Daniel Veillard
62ee5d5711 error message on vcpupin
* src/virsh.c: patch from Shigeki Sakamoto adding message on vcpupin
Daniel
2008-04-04 11:20:45 +00:00
Daniel Veillard
a528e97383 typos fixes
* docs//* src/conf.c src/hash.c src/libvirt.c src/proxy_internal.c
 src/remote_internal.c src/virsh.c src/xen_internal.c
 src/xend_internal.c src/xml.c: applied patch from Atsushi SAKAI
 fixing a lot of typos
Daniel
2008-04-04 07:58:29 +00:00
Jim Meyering
513bd04ce1 Mark many more strings for translation.
* Makefile.maint (err_func_re): Add to the list and make it readable.
* po/POTFILES.in: Add src/util.c and src/xm_internal.c, and sort.
* src/storage_backend.c: Fix comment.
* src/util.c (virFileLinkPointsTo): Mark a string.
* qemud/remote.c (remoteDispatchClientRequest): Mark strings.
(remoteDispatchOpen, CHECK_CONN, remoteDispatchGetType): Likewise.
(remoteDispatchDomainGetSchedulerType): Likewise.
(remoteDispatchDomainGetSchedulerParameters): Likewise.
(remoteDispatchDomainSetSchedulerParameters): Likewise.
(remoteDispatchDomainBlockStats): Likewise.
(remoteDispatchDomainInterfaceStats): Likewise.
(remoteDispatchDomainAttachDevice, remoteDispatchDomainCreate):
(remoteDispatchDomainDestroy, remoteDispatchDomainDetachDevice):
(remoteDispatchDomainDumpXml, remoteDispatchDomainGetAutostart):
(remoteDispatchDomainGetInfo, remoteDispatchDomainGetMaxMemory):
(remoteDispatchDomainGetMaxVcpus, remoteDispatchDomainGetOsType):
(remoteDispatchDomainGetVcpus): Likewise.
(remoteDispatchDomainMigratePerform): Likewise.
(remoteDispatchListDefinedDomains, remoteDispatchDomainPinVcpu):
(remoteDispatchDomainReboot, remoteDispatchDomainResume):
(remoteDispatchDomainSave, remoteDispatchDomainCoreDump):
(remoteDispatchDomainSetAutostart): Likewise.
(remoteDispatchDomainSetMaxMemory, remoteDispatchDomainSetMemory):
(remoteDispatchDomainSetVcpus, remoteDispatchDomainShutdown):
(remoteDispatchDomainSuspend, remoteDispatchDomainUndefine):
(remoteDispatchListDefinedNetworks, remoteDispatchListDomains):
(remoteDispatchListNetworks, remoteDispatchNetworkCreate):
(remoteDispatchNetworkDestroy, remoteDispatchNetworkDumpXml):
(remoteDispatchNetworkGetAutostart, remoteDispatchNetworkGetBridgeName):
(remoteDispatchNetworkSetAutostart, remoteDispatchNetworkUndefine):
(addrToString, remoteDispatchAuthSaslInit, remoteDispatchAuthSaslStart):
(remoteDispatchAuthSaslStep, remoteDispatchListDefinedStoragePools):
(remoteDispatchListStoragePools, remoteDispatchStoragePoolCreate):
(remoteDispatchStoragePoolBuild, remoteDispatchStoragePoolDestroy):
(remoteDispatchStoragePoolDelete, remoteDispatchStoragePoolRefresh):
(remoteDispatchStoragePoolGetInfo, remoteDispatchStoragePoolDumpXml):
(remoteDispatchStoragePoolGetAutostart): Likewise.
(remoteDispatchStoragePoolSetAutostart):
(remoteDispatchStoragePoolListVolumes):
(remoteDispatchStoragePoolNumOfVolumes):
(remoteDispatchStoragePoolUndefine, remoteDispatchStorageVolCreateXml):
(remoteDispatchStorageVolDelete, remoteDispatchStorageVolGetInfo):
(remoteDispatchStorageVolDumpXml, remoteDispatchStorageVolGetPath):
(remoteDispatchStorageVolLookupByName): Likewise.
* src/qemu_driver.c (qemudOpenMonitor, qemudStartVMDaemon):
(dhcpStartDhcpDaemon, qemudStartNetworkDaemon):
(qemudDomainSuspend, qemudDomainResume, qemudDomainShutdown):
(qemudDomainGetOSType, qemudDomainSetMaxMemory):
(qemudDomainSetMemory, qemudDomainGetInfo, qemudDomainSave):
(qemudDomainRestore, qemudDomainDumpXML, qemudDomainStart):
(qemudDomainUndefine, qemudDomainChangeCDROM):
(qemudDomainAttachDevice, qemudDomainGetAutostart):
(qemudDomainSetAutostart, qemudDomainInterfaceStats):
(qemudNetworkLookupByUUID, qemudNetworkLookupByName):
(qemudNetworkUndefine, qemudNetworkStart, qemudNetworkDestroy):
(qemudNetworkDumpXML, qemudNetworkGetAutostart):
(qemudNetworkSetAutostart): Likewise.
* src/virsh.c (cmdVcpupin, cmdAttachDevice, cmdDetachDevice): Likewise.
* src/xm_internal.c (xenXMConfigCacheRefresh, xenXMDomainPinVcpu): Likewise.
2008-03-27 13:43:01 +00:00
Richard W.M. Jones
dc1824b780 Tue Mar 25 10:23:00 UTC 2008 Richard W.M. Jones <rjones@redhat.com>
* src/virsh.c: Additional error messages for missing
         parameters (Shigeki Sakamoto).
2008-03-25 10:26:32 +00:00
Daniel Veillard
a7892ee000 String fixes #436620
* qemud/qemud.c src/virsh.c: fixing some user facing strings
  problems pointed out by Francesco Tombolini should fix #436620
Daniel
2008-03-14 15:21:15 +00:00
Daniel Veillard
dc232cdf1b * src/bridge.c src/virsh.c: typo fixes from Atsushi SAKAI
daniel
2008-03-13 09:21:41 +00:00
Daniel P. Berrange
c3501d4792 Don't force Xen connections to readonly when non-root 2008-03-11 14:25:49 +00:00
Richard W.M. Jones
4d6a8a1c0a Report error when vcpupin is given bad vCPU number.
* src/virsh.c: Report error when vcpupin is given bad vCPU number
	  (Shigeki Sakamoto).
2008-03-04 19:59:56 +00:00
Richard W.M. Jones
92a1e14b0b virMacAddrCompare for comparing MAC addresses
* src/util.c, src/util.h, src/libvirt_sym.version: Added
	  virMacAddrCompare utility function for comparing MAC
	  addresses.
	* src/virsh.c, src/xm_internal.c: Use virMacAddrCompare
	  to compare addresses.  (Shigeki Sakamoto and Richard Jones).
2008-02-27 16:14:44 +00:00
Jim Meyering
b59d9c85f1 Use safewrite in place of write, in many cases.
Also add "make syntax-check" rules to ensure no new uses sneak in.

There are many uses of write like this:

    if (write (fd, xml, towrite) != towrite)
        return -1;

The problem is that the syscall can succeed, yet write less than
the requested number of bytes, so the caller should retry
rather than simply failing.

This patch changes most of them to use util.c's safewrite wrapper,
which encapsulates the process.  Also, there were a few cases in
which the retry loop was open-coded, and I replaced those, too.

* Makefile.maint (sc_avoid_write): New rule, to avoid recurrence.
* .x-sc_avoid_write: New file.  Record two legitimate exemptions.
* qemud/qemud.c (sig_handler, qemudClientWriteBuf): Use safewrite, not write.
* src/conf.c (__virConfWriteFile): Likewise.
* src/qemu_conf.c (qemudSaveConfig, qemudSaveNetworkConfig): Likewise.
* src/qemu_driver.c (qemudWaitForMonitor, qemudStartVMDaemon)
(qemudVMData, PROC_IP_FORWARD): Likewise.
* proxy/libvirt_proxy.c: Include "util.h".
(proxyWriteClientSocket): Use safewrite.
* src/test.c (testDomainSave, testDomainCoreDump): Likewise.
* src/proxy_internal.c (virProxyWriteClientSocket): Likewise.
* src/virsh.c: Include "util-lib.h".
(vshOutputLogFile): Use safewrite.
* src/console.c: Include "util-lib.h".
(vshRunConsole): Use safewrite.
2008-02-22 15:55:04 +00:00
Daniel P. Berrange
f43e709842 Added convenience virsh command for creating pools/volumes without XML 2008-02-20 15:29:13 +00:00
Daniel P. Berrange
816fd02876 Added virsh commands for storage management 2008-02-20 15:27:08 +00:00
Mark McLoughlin
3da5504e68 Fix gcc-4.3.0 "inlining failed" warning.
* src/internal.h: move xstrol() variants from here ...

* src/util.[ch]: ... to here and rename to virStrToLong()

* src/libvirt_sym.version: export __virStrToLong_i() for
virsh and qemud.

* src/nodeinfo.c, src/stats_linux.c, src/virsh.c,
  src/xend_internal.c, qemud/qemud.c: replace xstrtol()
calls with virStrToLong()

* src/nodeinfo.h: don't include internal.h, which was only
needed for xstrtol(), but instead include libvirt.h which
is suffificient for the declarations in the header.
2008-02-08 09:15:16 +00:00
Jim Meyering
e8ff93b4e6 Remove more useless if tests before "free"-like functions.
* build-aux/useless-if-before-free: Rename from ...
* build-aux/find-unnecessary-if-before-free: ... this.  Remove file.
Also changed it so that new names are no longer hard-coded in the
script.  Instead, they're supplied via options:
* Makefile.cfg (useless_free_options): Define.
Add xmlXPathFreeObject to the list of free-like functions it detects.
* Makefile.maint (sc_avoid_if_before_free): Reflect script renaming.
* .x-sc_avoid_if_before_free: Likewise.
* src/openvz_conf.c (openvzParseXML): Remove useless "if"-before-free.
* src/qemu_conf.c (qemudParseXML, qemudParseNetworkXML): Likewise.
* src/virsh.c (cmdVNCDisplay, cmdTTYConsole, cmdDetachInterface):
(cmdDetachDisk): Likewise.
* src/xm_internal.c (xenXMConfigSetIntFromXPath): Likewise.
(xenXMConfigSetStringFromXPath, xenXMParseXMLToConfig): Likewise.
(xenXMDomainAttachDevice, xenXMAttachDisk, xenXMAttachInterface):
(xenXMDomainDetachDevice): Likewise.
* src/xml.c (virXPathString): Likewise.
* tests/xmlrpctest.c (checkRequestValue): Likewise.
2008-02-07 16:49:29 +00:00
Jim Meyering
e04912a9f0 Remove all trailing blanks; turn on the rule to detect them.
* Makefile.cfg (local-checks-to-skip): Remove sc_trailing_blank.
* .x-sc_trailing_blank: New file, to exempt the few binary files.
2008-02-05 19:27:37 +00:00
Jim Meyering
e99570fc77 Mark a string for translation.
* src/virsh.c: Add a "%s" and wrap with _(...).
2008-02-04 14:58:47 +00:00
Jim Meyering
f5f530f33f Avoid virsh leaks due to missing virDomainFree(dom) calls
* src/virsh.c (cmdDomuuid): Add missing virDomainFree call.
(cmdAttachDevice): Likewise.
(cmdDetachDevice): Likewise.
2008-01-30 19:58:59 +00:00
Jim Meyering
a1d2d2b21c src/virsh.c (cmdCapabilities): Plug a small leak. 2008-01-30 19:57:54 +00:00
Jim Meyering
2367caa327 Also detect and remove unnecessary if-before-xmlXPathFreeContext.
* build-aux/find-unnecessary-if-before-free: Update regexp.
* src/openvz_conf.c: Remove unnecessary "if (P)"-before xmlXPathFreeContext.
* src/qemu_conf.c: Likewise.
* src/virsh.c: Likewise.
* src/xm_internal.c: Likewise.
* src/xml.c: Likewise.
* tests/xmlrpctest.c: Likewise.
2008-01-29 18:23:43 +00:00
Jim Meyering
a378188194 Enable the <config.h>-requiring test; fix violations
Use <config.h>, not "config.h", per autoconf documentation.
* Makefile.cfg (local-checks-to-skip) [sc_require_config_h]: Enable.
* .x-sc_require_config_h: New file, to list exempted files.
* Makefile.am (EXTRA_DIST): Add .x-sc_require_config_h.
2008-01-29 18:15:54 +00:00
Jim Meyering
acff2d11ac Given code like if (foo) free (foo); remove the useless "if (foo) " part.
Likewise, given if (foo != NULL) free (foo); remove the useless "if" test.

* proxy/libvirt_proxy.c: Remove unnecessary "if" test before free.
* python/generator.py: Likewise.
* qemud/qemud.c: Likewise.
* src/buf.c: Likewise.
* src/conf.c: Likewise.
* src/hash.c: Likewise.
* src/iptables.c: Likewise.
* src/libvirt.c: Likewise.
* src/openvz_conf.c: Likewise.
* src/qemu_conf.c: Likewise.
* src/qemu_driver.c: Likewise.
* src/remote_internal.c: Likewise.
* src/test.c: Likewise.
* src/virsh.c: Likewise.
* src/virterror.c: Likewise.
* src/xen_internal.c: Likewise.
* src/xen_unified.c: Likewise.
* src/xend_internal.c: Likewise.
* src/xm_internal.c: Likewise.
* src/xml.c: Likewise.
* src/xmlrpc.c: Likewise.
* src/xs_internal.c: Likewise.
* tests/testutils.c: Likewise.
* tests/xencapstest.c: Likewise.
* tests/xmconfigtest.c: Likewise.
2008-01-29 17:41:07 +00:00
Daniel P. Berrange
45738083a6 Use virFileReadAll in virsh.c 2008-01-21 15:27:14 +00:00
Jim Meyering
42e5d20ae9 Avoid format string warnings.
* src/virsh.c: Add "%s" where needed.
* src/proxy_internal.c: Likewise.
2008-01-16 17:13:23 +00:00
Richard W.M. Jones
0d14fc0cbb Fri Dec 7 14:49:00 UTC 2007 Richard W.M. Jones <rjones@redhat.com>
* src/console.c, src/console.h, src/virsh.c: Disable
	  text console on Windows.
	* src/libvirt.c: Use replacement getpass from Gnulib.
	* src/libvirt.c: Initialize Winsock before use.
	* src/remote_internal.c: Header file fixes for Windows.
	  Don't fail if AI_ADDRCONFIG isn't defined.  Disable
	  unsupported stuff under Windows.
	* src/uuid.c: ENODATA unavailable on Windows, use EIO instead.
	* src/virsh.c: No uid_t / getuid on Windows.
	* src/virsh.c: No O_SYNC on Windows.
2007-12-07 14:56:37 +00:00
Richard W.M. Jones
efd495d667 Thu Dec 6 16:32:00 UTC 2007 Richard W.M. Jones <rjones@redhat.com>
* src/virsh.c: The prompt should depend on readonly status,
	  not on the UID.
2007-12-06 16:36:21 +00:00
Daniel Veillard
7633453cfa * configure.in src/Makefile.am src/virsh.c: fix compilation problems
when readline headers were found but not the library
Daniel
2007-12-06 10:24:52 +00:00
Daniel P. Berrange
e332ccdf71 Wire up SASL interaction callbacks to libvirt callbacks. Provide default callback impl 2007-12-05 18:55:04 +00:00