mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-05 22:05:47 +00:00
command.html.in: Kill useless spaces in <pre/>
The <pre/> section is rendered as-is on the page. That is, if all the lines are prefixed with 4 spaces the rendered page will also have them. Problem is if we put a box around such <pre/> because the content might not fix into it. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
4753d88c39
commit
e693c444af
@ -83,7 +83,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
virCommandPtr cmd = virCommandNew("/usr/bin/dnsmasq");
|
virCommandPtr cmd = virCommandNew("/usr/bin/dnsmasq");
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -100,7 +100,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
virCommandAddArg(cmd, "-strict-order");
|
virCommandAddArg(cmd, "-strict-order");
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -109,7 +109,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
virCommandAddArgPair(cmd, "--conf-file", "/etc/dnsmasq.conf");
|
virCommandAddArgPair(cmd, "--conf-file", "/etc/dnsmasq.conf");
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -118,7 +118,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
virCommandAddArgFormat(cmd, "%d", count);
|
virCommandAddArgFormat(cmd, "%d", count);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -127,11 +127,11 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
const char *const args[] = {
|
const char *const args[] = {
|
||||||
"--strict-order", "--except-interface", "lo", NULL
|
"--strict-order", "--except-interface", "lo", NULL
|
||||||
};
|
};
|
||||||
virCommandAddArgSet(cmd, args);
|
virCommandAddArgSet(cmd, args);
|
||||||
virCommandAddArgList(cmd, "--domain", "localdomain", NULL);
|
virCommandAddArgList(cmd, "--domain", "localdomain", NULL);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -140,14 +140,14 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
const char *const args[] = {
|
const char *const args[] = {
|
||||||
"/usr/bin/dnsmasq",
|
"/usr/bin/dnsmasq",
|
||||||
"--strict-order", "--except-interface",
|
"--strict-order", "--except-interface",
|
||||||
"lo", "--domain", "localdomain", NULL
|
"lo", "--domain", "localdomain", NULL
|
||||||
};
|
};
|
||||||
virCommandPtr cmd1 = virCommandNewArgs(cmd, args);
|
virCommandPtr cmd1 = virCommandNewArgs(cmd, args);
|
||||||
virCommandPtr cmd2 = virCommandNewArgList("/usr/bin/dnsmasq",
|
virCommandPtr cmd2 = virCommandNewArgList("/usr/bin/dnsmasq",
|
||||||
"--domain", "localdomain", NULL);
|
"--domain", "localdomain", NULL);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3><a name="env">Setting up the environment</a></h3>
|
<h3><a name="env">Setting up the environment</a></h3>
|
||||||
@ -163,7 +163,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
virCommandAddEnvPassCommon(cmd);
|
virCommandAddEnvPassCommon(cmd);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -177,8 +177,8 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
virCommandAddEnvPass(cmd, "DISPLAY");
|
virCommandAddEnvPass(cmd, "DISPLAY");
|
||||||
virCommandAddEnvPass(cmd, "XAUTHORITY");
|
virCommandAddEnvPass(cmd, "XAUTHORITY");
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -187,7 +187,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
virCommandAddEnvPair(cmd, "TERM", "xterm");
|
virCommandAddEnvPair(cmd, "TERM", "xterm");
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -196,7 +196,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
virCommandAddEnvString(cmd, "TERM=xterm");
|
virCommandAddEnvString(cmd, "TERM=xterm");
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3><a name="misc">Miscellaneous other options</a></h3>
|
<h3><a name="misc">Miscellaneous other options</a></h3>
|
||||||
@ -210,7 +210,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
virCommandDaemonize(cmd);
|
virCommandDaemonize(cmd);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -221,7 +221,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
virCommandSetPidFile(cmd, "/var/run/dnsmasq.pid");
|
virCommandSetPidFile(cmd, "/var/run/dnsmasq.pid");
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -240,7 +240,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
virCommandClearCaps(cmd);
|
virCommandClearCaps(cmd);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3><a name="fds">Managing file handles</a></h3>
|
<h3><a name="fds">Managing file handles</a></h3>
|
||||||
@ -256,13 +256,13 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
int sharedfd = open("cmd.log", "w+");
|
int sharedfd = open("cmd.log", "w+");
|
||||||
int childfd = open("conf.txt", "r");
|
int childfd = open("conf.txt", "r");
|
||||||
virCommandPassFD(cmd, sharedfd, 0);
|
virCommandPassFD(cmd, sharedfd, 0);
|
||||||
virCommandPassFD(cmd, childfd,
|
virCommandPassFD(cmd, childfd,
|
||||||
VIR_COMMAND_PASS_FD_CLOSE_PARENT);
|
VIR_COMMAND_PASS_FD_CLOSE_PARENT);
|
||||||
if (VIR_CLOSE(sharedfd) < 0)
|
if (VIR_CLOSE(sharedfd) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -282,7 +282,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
virCommandSetInputFD(cmd, 7);
|
virCommandSetInputFD(cmd, 7);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -291,10 +291,10 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
int outfd = open("out.log", "w+");
|
int outfd = open("out.log", "w+");
|
||||||
int errfd = open("err.log", "w+");
|
int errfd = open("err.log", "w+");
|
||||||
virCommandSetOutputFD(cmd, &outfd);
|
virCommandSetOutputFD(cmd, &outfd);
|
||||||
virCommandSetErrorFD(cmd, &errfd);
|
virCommandSetErrorFD(cmd, &errfd);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -304,10 +304,10 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
int outfd = -1;
|
int outfd = -1;
|
||||||
int errfd = -1
|
int errfd = -1
|
||||||
virCommandSetOutputFD(cmd, &outfd);
|
virCommandSetOutputFD(cmd, &outfd);
|
||||||
virCommandSetErrorFD(cmd, &errfd);
|
virCommandSetErrorFD(cmd, &errfd);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -326,7 +326,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
virCommandNonblockingFDs(cmd);
|
virCommandNonblockingFDs(cmd);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3><a name="buffers">Feeding & capturing strings to/from the child</a></h3>
|
<h3><a name="buffers">Feeding & capturing strings to/from the child</a></h3>
|
||||||
@ -350,8 +350,8 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
const char *input = "Hello World\n";
|
const char *input = "Hello World\n";
|
||||||
virCommandSetInputBuffer(cmd, input);
|
virCommandSetInputBuffer(cmd, input);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -362,9 +362,9 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
char *output = NULL, *errors = NULL;
|
char *output = NULL, *errors = NULL;
|
||||||
virCommandSetOutputBuffer(cmd, &output);
|
virCommandSetOutputBuffer(cmd, &output);
|
||||||
virCommandSetErrorBuffer(cmd, &errors);
|
virCommandSetErrorBuffer(cmd, &errors);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -392,7 +392,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
virCommandSetWorkingDirectory(cmd, LOCALSTATEDIR);
|
virCommandSetWorkingDirectory(cmd, LOCALSTATEDIR);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3><a name="hooks">Any additional hooks</a></h3>
|
<h3><a name="hooks">Any additional hooks</a></h3>
|
||||||
@ -406,7 +406,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
virCommandSetPreExecHook(cmd, hook, opaque);
|
virCommandSetPreExecHook(cmd, hook, opaque);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3><a name="logging">Logging commands</a></h3>
|
<h3><a name="logging">Logging commands</a></h3>
|
||||||
@ -418,20 +418,20 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
int logfd = ...;
|
int logfd = ...;
|
||||||
char *timestamp = virTimestamp();
|
char *timestamp = virTimestamp();
|
||||||
char *string = NULL;
|
char *string = NULL;
|
||||||
|
|
||||||
dprintf(logfd, "%s: ", timestamp);
|
dprintf(logfd, "%s: ", timestamp);
|
||||||
VIR_FREE(timestamp);
|
VIR_FREE(timestamp);
|
||||||
virCommandWriteArgLog(cmd, logfd);
|
virCommandWriteArgLog(cmd, logfd);
|
||||||
|
|
||||||
string = virCommandToString(cmd);
|
string = virCommandToString(cmd);
|
||||||
if (string)
|
if (string)
|
||||||
VIR_DEBUG("about to run %s", string);
|
VIR_DEBUG("about to run %s", string);
|
||||||
VIR_FREE(string);
|
VIR_FREE(string);
|
||||||
if (virCommandRun(cmd, NULL) < 0)
|
if (virCommandRun(cmd, NULL) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3><a name="sync">Running commands synchronously</a></h3>
|
<h3><a name="sync">Running commands synchronously</a></h3>
|
||||||
@ -443,8 +443,8 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
if (virCommandRun(cmd, NULL) < 0)
|
if (virCommandRun(cmd, NULL) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -465,19 +465,19 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
int status;
|
int status;
|
||||||
if (virCommandRun(cmd, &status) < 0)
|
if (virCommandRun(cmd, &status) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (status == 1) {
|
if (status == 1) {
|
||||||
...do stuff...
|
...do stuff...
|
||||||
}
|
}
|
||||||
|
|
||||||
virCommandRawStatus(cmd2);
|
virCommandRawStatus(cmd2);
|
||||||
if (virCommandRun(cmd2, &status) < 0)
|
if (virCommandRun(cmd2, &status) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (WIFEXITED(status) && WEXITSTATUS(status) == 1) {
|
if (WIFEXITED(status) && WEXITSTATUS(status) == 1) {
|
||||||
...do stuff...
|
...do stuff...
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3><a name="async">Running commands asynchronously</a></h3>
|
<h3><a name="async">Running commands asynchronously</a></h3>
|
||||||
@ -490,19 +490,19 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
if (virCommandRunAsync(cmd, &pid) < 0)
|
if (virCommandRunAsync(cmd, &pid) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
... do something while pid is running ...
|
... do something while pid is running ...
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
if (virCommandWait(cmd, &status) < 0)
|
if (virCommandWait(cmd, &status) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (WEXITSTATUS(status)...) {
|
if (WEXITSTATUS(status)...) {
|
||||||
..do stuff..
|
..do stuff..
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -540,7 +540,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
virCommandFree(cmd);
|
virCommandFree(cmd);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
Loading…
Reference in New Issue
Block a user