~nova-coresec/ubuntu/maverick/libvirt/nova-ppa

« back to all changes in this revision

Viewing changes to tools/virsh.c

  • Committer: Bazaar Package Importer
  • Author(s): Guido Günther
  • Date: 2010-04-19 18:11:57 UTC
  • mto: (3.4.14 squeeze) (1.2.5 upstream)
  • mto: This revision was merged to the branch mainline in revision 92.
  • Revision ID: james.westby@ubuntu.com-20100419181157-yyj82wyh90r6wxwr
Tags: upstream-0.8.0
Import upstream version 0.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include <errno.h>
31
31
#include <sys/stat.h>
32
32
#include <inttypes.h>
 
33
#include <signal.h>
33
34
 
34
35
#include <libxml/parser.h>
35
36
#include <libxml/tree.h>
37
38
#include <libxml/xmlsave.h>
38
39
 
39
40
#ifdef HAVE_READLINE_READLINE_H
40
 
#include <readline/readline.h>
41
 
#include <readline/history.h>
 
41
# include <readline/readline.h>
 
42
# include <readline/history.h>
42
43
#endif
43
44
 
44
45
#include "internal.h"
48
49
#include "console.h"
49
50
#include "util.h"
50
51
#include "memory.h"
 
52
#include "xml.h"
51
53
 
52
54
static char *progname;
53
55
 
54
56
#ifndef TRUE
55
 
#define TRUE 1
56
 
#define FALSE 0
 
57
# define TRUE 1
 
58
# define FALSE 0
57
59
#endif
58
60
 
59
61
#define VIRSH_MAX_XML_FILE 10*1024*1024
226
228
static int vshCommandOptInt(const vshCmd *cmd, const char *name, int *found);
227
229
static char *vshCommandOptString(const vshCmd *cmd, const char *name,
228
230
                                 int *found);
 
231
static long long vshCommandOptLongLong(const vshCmd *cmd, const char *name,
 
232
                                       int *found);
229
233
#if 0
230
234
static int vshCommandOptStringList(const vshCmd *cmd, const char *name, char ***data);
231
235
#endif
251
255
    vshCommandOptNetworkBy(_ctl, _cmd, _name,                      \
252
256
                           VSH_BYUUID|VSH_BYNAME)
253
257
 
 
258
static virNWFilterPtr vshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd,
 
259
                                                  char **name, int flag);
 
260
 
 
261
/* default is lookup by Name and UUID */
 
262
#define vshCommandOptNWFilter(_ctl, _cmd, _name)                    \
 
263
    vshCommandOptNWFilterBy(_ctl, _cmd, _name,                      \
 
264
                            VSH_BYUUID|VSH_BYNAME)
 
265
 
254
266
static virInterfacePtr vshCommandOptInterfaceBy(vshControl *ctl, const vshCmd *cmd,
255
267
                                                char **name, int flag);
256
268
 
397
409
    last_error = NULL;
398
410
}
399
411
 
 
412
/*
 
413
 * Detection of disconnections and automatic reconnection support
 
414
 */
 
415
static int disconnected = 0; /* we may have been disconnected */
 
416
 
 
417
#ifdef SIGPIPE
 
418
/*
 
419
 * vshCatchDisconnect:
 
420
 *
 
421
 * We get here when a SIGPIPE is being raised, we can't do much in the
 
422
 * handler, just save the fact it was raised
 
423
 */
 
424
static void vshCatchDisconnect(int sig, siginfo_t * siginfo,
 
425
                               void* context ATTRIBUTE_UNUSED) {
 
426
    if ((sig == SIGPIPE) || (siginfo->si_signo == SIGPIPE))
 
427
        disconnected++;
 
428
}
 
429
 
 
430
/*
 
431
 * vshSetupSignals:
 
432
 *
 
433
 * Catch SIGPIPE signals which may arise when disconnection
 
434
 * from libvirtd occurs
 
435
 */
 
436
static void
 
437
vshSetupSignals(void) {
 
438
    struct sigaction sig_action;
 
439
 
 
440
    sig_action.sa_sigaction = vshCatchDisconnect;
 
441
    sig_action.sa_flags = SA_SIGINFO;
 
442
    sigemptyset(&sig_action.sa_mask);
 
443
 
 
444
    sigaction(SIGPIPE, &sig_action, NULL);
 
445
}
 
446
#else
 
447
static void
 
448
vshSetupSignals(void) {}
 
449
#endif
 
450
 
 
451
/*
 
452
 * vshReconnect:
 
453
 *
 
454
 * Reconnect after a disconnect from libvirtd
 
455
 *
 
456
 */
 
457
static void
 
458
vshReconnect(vshControl *ctl) {
 
459
    if (ctl->conn != NULL)
 
460
        virConnectClose(ctl->conn);
 
461
 
 
462
    ctl->conn = virConnectOpenAuth(ctl->name,
 
463
                                   virConnectAuthPtrDefault,
 
464
                                   ctl->readonly ? VIR_CONNECT_RO : 0);
 
465
    if (!ctl->conn)
 
466
        vshError(ctl, "%s", _("Failed to reconnect to the hypervisor"));
 
467
    else
 
468
        vshError(ctl, "%s", _("Reconnected to the hypervisor"));
 
469
    disconnected = 0;
 
470
}
400
471
 
401
472
/* ---------------
402
473
 * Commands
407
478
 * "help" command
408
479
 */
409
480
static const vshCmdInfo info_help[] = {
410
 
    {"help", gettext_noop("print help")},
411
 
    {"desc", gettext_noop("Prints global help or command specific help.")},
 
481
    {"help", N_("print help")},
 
482
    {"desc", N_("Prints global help or command specific help.")},
412
483
 
413
484
    {NULL, NULL}
414
485
};
415
486
 
416
487
static const vshCmdOptDef opts_help[] = {
417
 
    {"command", VSH_OT_DATA, 0, gettext_noop("name of command")},
 
488
    {"command", VSH_OT_DATA, 0, N_("name of command")},
418
489
    {NULL, 0, 0, NULL}
419
490
};
420
491
 
429
500
        vshPrint(ctl, "%s", _("Commands:\n\n"));
430
501
        for (def = commands; def->name; def++)
431
502
            vshPrint(ctl, "    %-15s %s\n", def->name,
432
 
                     N_(vshCmddefGetInfo(def, "help")));
 
503
                     _(vshCmddefGetInfo(def, "help")));
433
504
        return TRUE;
434
505
    }
435
506
    return vshCmddefHelp(ctl, cmdname);
439
510
 * "autostart" command
440
511
 */
441
512
static const vshCmdInfo info_autostart[] = {
442
 
    {"help", gettext_noop("autostart a domain")},
 
513
    {"help", N_("autostart a domain")},
443
514
    {"desc",
444
 
     gettext_noop("Configure a domain to be automatically started at boot.")},
 
515
     N_("Configure a domain to be automatically started at boot.")},
445
516
    {NULL, NULL}
446
517
};
447
518
 
448
519
static const vshCmdOptDef opts_autostart[] = {
449
 
    {"domain",  VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
450
 
    {"disable", VSH_OT_BOOL, 0, gettext_noop("disable autostarting")},
 
520
    {"domain",  VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
521
    {"disable", VSH_OT_BOOL, 0, N_("disable autostarting")},
451
522
    {NULL, 0, 0, NULL}
452
523
};
453
524
 
488
559
 * "connect" command
489
560
 */
490
561
static const vshCmdInfo info_connect[] = {
491
 
    {"help", gettext_noop("(re)connect to hypervisor")},
 
562
    {"help", N_("(re)connect to hypervisor")},
492
563
    {"desc",
493
 
     gettext_noop("Connect to local hypervisor. This is built-in command after shell start up.")},
 
564
     N_("Connect to local hypervisor. This is built-in command after shell start up.")},
494
565
    {NULL, NULL}
495
566
};
496
567
 
497
568
static const vshCmdOptDef opts_connect[] = {
498
 
    {"name",     VSH_OT_DATA, 0, gettext_noop("hypervisor connection URI")},
499
 
    {"readonly", VSH_OT_BOOL, 0, gettext_noop("read-only connection")},
 
569
    {"name",     VSH_OT_DATA, 0, N_("hypervisor connection URI")},
 
570
    {"readonly", VSH_OT_BOOL, 0, N_("read-only connection")},
500
571
    {NULL, 0, 0, NULL}
501
572
};
502
573
 
537
608
 * "console" command
538
609
 */
539
610
static const vshCmdInfo info_console[] = {
540
 
    {"help", gettext_noop("connect to the guest console")},
 
611
    {"help", N_("connect to the guest console")},
541
612
    {"desc",
542
 
     gettext_noop("Connect the virtual serial console for the guest")},
 
613
     N_("Connect the virtual serial console for the guest")},
543
614
    {NULL, NULL}
544
615
};
545
616
 
546
617
static const vshCmdOptDef opts_console[] = {
547
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
 
618
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
548
619
    {NULL, 0, 0, NULL}
549
620
};
550
621
 
646
717
 * "list" command
647
718
 */
648
719
static const vshCmdInfo info_list[] = {
649
 
    {"help", gettext_noop("list domains")},
650
 
    {"desc", gettext_noop("Returns list of domains.")},
 
720
    {"help", N_("list domains")},
 
721
    {"desc", N_("Returns list of domains.")},
651
722
    {NULL, NULL}
652
723
};
653
724
 
654
725
static const vshCmdOptDef opts_list[] = {
655
 
    {"inactive", VSH_OT_BOOL, 0, gettext_noop("list inactive domains")},
656
 
    {"all", VSH_OT_BOOL, 0, gettext_noop("list inactive & active domains")},
 
726
    {"inactive", VSH_OT_BOOL, 0, N_("list inactive domains")},
 
727
    {"all", VSH_OT_BOOL, 0, N_("list inactive & active domains")},
657
728
    {NULL, 0, 0, NULL}
658
729
};
659
730
 
725
796
        if (virDomainGetInfo(dom, &info) < 0)
726
797
            state = _("no state");
727
798
        else
728
 
            state = N_(vshDomainStateToString(info.state));
 
799
            state = _(vshDomainStateToString(info.state));
729
800
 
730
801
        vshPrint(ctl, "%3d %-20s %s\n",
731
802
                 virDomainGetID(dom),
747
818
        if (virDomainGetInfo(dom, &info) < 0)
748
819
            state = _("no state");
749
820
        else
750
 
            state = N_(vshDomainStateToString(info.state));
 
821
            state = _(vshDomainStateToString(info.state));
751
822
 
752
823
        vshPrint(ctl, "%3s %-20s %s\n", "-", names[i], state);
753
824
 
763
834
 * "domstate" command
764
835
 */
765
836
static const vshCmdInfo info_domstate[] = {
766
 
    {"help", gettext_noop("domain state")},
767
 
    {"desc", gettext_noop("Returns state about a domain.")},
 
837
    {"help", N_("domain state")},
 
838
    {"desc", N_("Returns state about a domain.")},
768
839
    {NULL, NULL}
769
840
};
770
841
 
771
842
static const vshCmdOptDef opts_domstate[] = {
772
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
 
843
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
773
844
    {NULL, 0, 0, NULL}
774
845
};
775
846
 
788
859
 
789
860
    if (virDomainGetInfo(dom, &info) == 0)
790
861
        vshPrint(ctl, "%s\n",
791
 
                 N_(vshDomainStateToString(info.state)));
 
862
                 _(vshDomainStateToString(info.state)));
792
863
    else
793
864
        ret = FALSE;
794
865
 
799
870
/* "domblkstat" command
800
871
 */
801
872
static const vshCmdInfo info_domblkstat[] = {
802
 
    {"help", gettext_noop("get device block stats for a domain")},
803
 
    {"desc", gettext_noop("Get device block stats for a running domain.")},
 
873
    {"help", N_("get device block stats for a domain")},
 
874
    {"desc", N_("Get device block stats for a running domain.")},
804
875
    {NULL,NULL}
805
876
};
806
877
 
807
878
static const vshCmdOptDef opts_domblkstat[] = {
808
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
809
 
    {"device", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("block device")},
 
879
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
880
    {"device", VSH_OT_DATA, VSH_OFLAG_REQ, N_("block device")},
810
881
    {NULL, 0, 0, NULL}
811
882
};
812
883
 
856
927
/* "domifstat" command
857
928
 */
858
929
static const vshCmdInfo info_domifstat[] = {
859
 
    {"help", gettext_noop("get network interface stats for a domain")},
860
 
    {"desc", gettext_noop("Get network interface stats for a running domain.")},
 
930
    {"help", N_("get network interface stats for a domain")},
 
931
    {"desc", N_("Get network interface stats for a running domain.")},
861
932
    {NULL,NULL}
862
933
};
863
934
 
864
935
static const vshCmdOptDef opts_domifstat[] = {
865
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
866
 
    {"interface", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("interface device")},
 
936
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
937
    {"interface", VSH_OT_DATA, VSH_OFLAG_REQ, N_("interface device")},
867
938
    {NULL, 0, 0, NULL}
868
939
};
869
940
 
923
994
 * "dommemstats" command
924
995
 */
925
996
static const vshCmdInfo info_dommemstat[] = {
926
 
    {"help", gettext_noop("get memory statistics for a domain")},
927
 
    {"desc", gettext_noop("Get memory statistics for a runnng domain.")},
 
997
    {"help", N_("get memory statistics for a domain")},
 
998
    {"desc", N_("Get memory statistics for a runnng domain.")},
928
999
    {NULL,NULL}
929
1000
};
930
1001
 
931
1002
static const vshCmdOptDef opts_dommemstat[] = {
932
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
 
1003
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
933
1004
    {NULL, 0, 0, NULL}
934
1005
};
935
1006
 
977
1048
 * "suspend" command
978
1049
 */
979
1050
static const vshCmdInfo info_suspend[] = {
980
 
    {"help", gettext_noop("suspend a domain")},
981
 
    {"desc", gettext_noop("Suspend a running domain.")},
 
1051
    {"help", N_("suspend a domain")},
 
1052
    {"desc", N_("Suspend a running domain.")},
982
1053
    {NULL, NULL}
983
1054
};
984
1055
 
985
1056
static const vshCmdOptDef opts_suspend[] = {
986
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
 
1057
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
987
1058
    {NULL, 0, 0, NULL}
988
1059
};
989
1060
 
1015
1086
 * "create" command
1016
1087
 */
1017
1088
static const vshCmdInfo info_create[] = {
1018
 
    {"help", gettext_noop("create a domain from an XML file")},
1019
 
    {"desc", gettext_noop("Create a domain.")},
 
1089
    {"help", N_("create a domain from an XML file")},
 
1090
    {"desc", N_("Create a domain.")},
1020
1091
    {NULL, NULL}
1021
1092
};
1022
1093
 
1023
1094
static const vshCmdOptDef opts_create[] = {
1024
 
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("file containing an XML domain description")},
 
1095
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML domain description")},
1025
1096
#ifndef WIN32
1026
 
    {"console", VSH_OT_BOOL, 0, gettext_noop("attach to console after creation")},
 
1097
    {"console", VSH_OT_BOOL, 0, N_("attach to console after creation")},
1027
1098
#endif
1028
1099
    {NULL, 0, 0, NULL}
1029
1100
};
1072
1143
 * "define" command
1073
1144
 */
1074
1145
static const vshCmdInfo info_define[] = {
1075
 
    {"help", gettext_noop("define (but don't start) a domain from an XML file")},
1076
 
    {"desc", gettext_noop("Define a domain.")},
 
1146
    {"help", N_("define (but don't start) a domain from an XML file")},
 
1147
    {"desc", N_("Define a domain.")},
1077
1148
    {NULL, NULL}
1078
1149
};
1079
1150
 
1080
1151
static const vshCmdOptDef opts_define[] = {
1081
 
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("file containing an XML domain description")},
 
1152
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML domain description")},
1082
1153
    {NULL, 0, 0, NULL}
1083
1154
};
1084
1155
 
1119
1190
 * "undefine" command
1120
1191
 */
1121
1192
static const vshCmdInfo info_undefine[] = {
1122
 
    {"help", gettext_noop("undefine an inactive domain")},
1123
 
    {"desc", gettext_noop("Undefine the configuration for an inactive domain.")},
 
1193
    {"help", N_("undefine an inactive domain")},
 
1194
    {"desc", N_("Undefine the configuration for an inactive domain.")},
1124
1195
    {NULL, NULL}
1125
1196
};
1126
1197
 
1127
1198
static const vshCmdOptDef opts_undefine[] = {
1128
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name or uuid")},
 
1199
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name or uuid")},
1129
1200
    {NULL, 0, 0, NULL}
1130
1201
};
1131
1202
 
1175
1246
 * "start" command
1176
1247
 */
1177
1248
static const vshCmdInfo info_start[] = {
1178
 
    {"help", gettext_noop("start a (previously defined) inactive domain")},
1179
 
    {"desc", gettext_noop("Start a domain.")},
 
1249
    {"help", N_("start a (previously defined) inactive domain")},
 
1250
    {"desc", N_("Start a domain.")},
1180
1251
    {NULL, NULL}
1181
1252
};
1182
1253
 
1183
1254
static const vshCmdOptDef opts_start[] = {
1184
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("name of the inactive domain")},
 
1255
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("name of the inactive domain")},
1185
1256
#ifndef WIN32
1186
 
    {"console", VSH_OT_BOOL, 0, gettext_noop("attach to console after creation")},
 
1257
    {"console", VSH_OT_BOOL, 0, N_("attach to console after creation")},
1187
1258
#endif
1188
1259
    {NULL, 0, 0, NULL}
1189
1260
};
1228
1299
 * "save" command
1229
1300
 */
1230
1301
static const vshCmdInfo info_save[] = {
1231
 
    {"help", gettext_noop("save a domain state to a file")},
1232
 
    {"desc", gettext_noop("Save a running domain.")},
 
1302
    {"help", N_("save a domain state to a file")},
 
1303
    {"desc", N_("Save a running domain.")},
1233
1304
    {NULL, NULL}
1234
1305
};
1235
1306
 
1236
1307
static const vshCmdOptDef opts_save[] = {
1237
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
1238
 
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("where to save the data")},
 
1308
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
1309
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("where to save the data")},
1239
1310
    {NULL, 0, 0, NULL}
1240
1311
};
1241
1312
 
1268
1339
}
1269
1340
 
1270
1341
/*
 
1342
 * "managedsave" command
 
1343
 */
 
1344
static const vshCmdInfo info_managedsave[] = {
 
1345
    {"help", N_("managed save of a domain state")},
 
1346
    {"desc", N_("Save and stop a running domain, so libvirt can restart it from the same state")},
 
1347
    {NULL, NULL}
 
1348
};
 
1349
 
 
1350
static const vshCmdOptDef opts_managedsave[] = {
 
1351
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
1352
    {NULL, 0, 0, NULL}
 
1353
};
 
1354
 
 
1355
static int
 
1356
cmdManagedSave(vshControl *ctl, const vshCmd *cmd)
 
1357
{
 
1358
    virDomainPtr dom;
 
1359
    char *name;
 
1360
    int ret = TRUE;
 
1361
 
 
1362
    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
 
1363
        return FALSE;
 
1364
 
 
1365
    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
 
1366
        return FALSE;
 
1367
 
 
1368
    if (virDomainManagedSave(dom, 0) == 0) {
 
1369
        vshPrint(ctl, _("Domain %s state saved by libvirt\n"), name);
 
1370
    } else {
 
1371
        vshError(ctl, _("Failed to save domain %s state"), name);
 
1372
        ret = FALSE;
 
1373
    }
 
1374
 
 
1375
    virDomainFree(dom);
 
1376
    return ret;
 
1377
}
 
1378
 
 
1379
/*
1271
1380
 * "schedinfo" command
1272
1381
 */
1273
1382
static const vshCmdInfo info_schedinfo[] = {
1274
 
    {"help", gettext_noop("show/set scheduler parameters")},
1275
 
    {"desc", gettext_noop("Show/Set scheduler parameters.")},
 
1383
    {"help", N_("show/set scheduler parameters")},
 
1384
    {"desc", N_("Show/Set scheduler parameters.")},
1276
1385
    {NULL, NULL}
1277
1386
};
1278
1387
 
1279
1388
static const vshCmdOptDef opts_schedinfo[] = {
1280
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
1281
 
    {"set", VSH_OT_STRING, VSH_OFLAG_NONE, gettext_noop("parameter=value")},
1282
 
    {"weight", VSH_OT_INT, VSH_OFLAG_NONE, gettext_noop("weight for XEN_CREDIT")},
1283
 
    {"cap", VSH_OT_INT, VSH_OFLAG_NONE, gettext_noop("cap for XEN_CREDIT")},
 
1389
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
1390
    {"set", VSH_OT_STRING, VSH_OFLAG_NONE, N_("parameter=value")},
 
1391
    {"weight", VSH_OT_INT, VSH_OFLAG_NONE, N_("weight for XEN_CREDIT")},
 
1392
    {"cap", VSH_OT_INT, VSH_OFLAG_NONE, N_("cap for XEN_CREDIT")},
1284
1393
    {NULL, 0, 0, NULL}
1285
1394
};
1286
1395
 
1477
1586
 * "restore" command
1478
1587
 */
1479
1588
static const vshCmdInfo info_restore[] = {
1480
 
    {"help", gettext_noop("restore a domain from a saved state in a file")},
1481
 
    {"desc", gettext_noop("Restore a domain.")},
 
1589
    {"help", N_("restore a domain from a saved state in a file")},
 
1590
    {"desc", N_("Restore a domain.")},
1482
1591
    {NULL, NULL}
1483
1592
};
1484
1593
 
1485
1594
static const vshCmdOptDef opts_restore[] = {
1486
 
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("the state to restore")},
 
1595
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("the state to restore")},
1487
1596
    {NULL, 0, 0, NULL}
1488
1597
};
1489
1598
 
1514
1623
 * "dump" command
1515
1624
 */
1516
1625
static const vshCmdInfo info_dump[] = {
1517
 
    {"help", gettext_noop("dump the core of a domain to a file for analysis")},
1518
 
    {"desc", gettext_noop("Core dump a domain.")},
 
1626
    {"help", N_("dump the core of a domain to a file for analysis")},
 
1627
    {"desc", N_("Core dump a domain.")},
1519
1628
    {NULL, NULL}
1520
1629
};
1521
1630
 
1522
1631
static const vshCmdOptDef opts_dump[] = {
1523
 
    {"live", VSH_OT_BOOL, 0, gettext_noop("perform a live core dump if supported")},
1524
 
    {"crash", VSH_OT_BOOL, 0, gettext_noop("crash the domain after core dump")},
1525
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
1526
 
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("where to dump the core")},
 
1632
    {"live", VSH_OT_BOOL, 0, N_("perform a live core dump if supported")},
 
1633
    {"crash", VSH_OT_BOOL, 0, N_("crash the domain after core dump")},
 
1634
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
1635
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("where to dump the core")},
1527
1636
    {NULL, 0, 0, NULL}
1528
1637
};
1529
1638
 
1565
1674
 * "resume" command
1566
1675
 */
1567
1676
static const vshCmdInfo info_resume[] = {
1568
 
    {"help", gettext_noop("resume a domain")},
1569
 
    {"desc", gettext_noop("Resume a previously suspended domain.")},
 
1677
    {"help", N_("resume a domain")},
 
1678
    {"desc", N_("Resume a previously suspended domain.")},
1570
1679
    {NULL, NULL}
1571
1680
};
1572
1681
 
1573
1682
static const vshCmdOptDef opts_resume[] = {
1574
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
 
1683
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
1575
1684
    {NULL, 0, 0, NULL}
1576
1685
};
1577
1686
 
1603
1712
 * "shutdown" command
1604
1713
 */
1605
1714
static const vshCmdInfo info_shutdown[] = {
1606
 
    {"help", gettext_noop("gracefully shutdown a domain")},
1607
 
    {"desc", gettext_noop("Run shutdown in the target domain.")},
 
1715
    {"help", N_("gracefully shutdown a domain")},
 
1716
    {"desc", N_("Run shutdown in the target domain.")},
1608
1717
    {NULL, NULL}
1609
1718
};
1610
1719
 
1611
1720
static const vshCmdOptDef opts_shutdown[] = {
1612
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
 
1721
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
1613
1722
    {NULL, 0, 0, NULL}
1614
1723
};
1615
1724
 
1641
1750
 * "reboot" command
1642
1751
 */
1643
1752
static const vshCmdInfo info_reboot[] = {
1644
 
    {"help", gettext_noop("reboot a domain")},
1645
 
    {"desc", gettext_noop("Run a reboot command in the target domain.")},
 
1753
    {"help", N_("reboot a domain")},
 
1754
    {"desc", N_("Run a reboot command in the target domain.")},
1646
1755
    {NULL, NULL}
1647
1756
};
1648
1757
 
1649
1758
static const vshCmdOptDef opts_reboot[] = {
1650
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
 
1759
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
1651
1760
    {NULL, 0, 0, NULL}
1652
1761
};
1653
1762
 
1679
1788
 * "destroy" command
1680
1789
 */
1681
1790
static const vshCmdInfo info_destroy[] = {
1682
 
    {"help", gettext_noop("destroy a domain")},
1683
 
    {"desc", gettext_noop("Destroy a given domain.")},
 
1791
    {"help", N_("destroy a domain")},
 
1792
    {"desc", N_("Destroy a given domain.")},
1684
1793
    {NULL, NULL}
1685
1794
};
1686
1795
 
1687
1796
static const vshCmdOptDef opts_destroy[] = {
1688
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
 
1797
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
1689
1798
    {NULL, 0, 0, NULL}
1690
1799
};
1691
1800
 
1717
1826
 * "dominfo" command
1718
1827
 */
1719
1828
static const vshCmdInfo info_dominfo[] = {
1720
 
    {"help", gettext_noop("domain information")},
1721
 
    {"desc", gettext_noop("Returns basic information about the domain.")},
 
1829
    {"help", N_("domain information")},
 
1830
    {"desc", N_("Returns basic information about the domain.")},
1722
1831
    {NULL, NULL}
1723
1832
};
1724
1833
 
1725
1834
static const vshCmdOptDef opts_dominfo[] = {
1726
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
 
1835
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
1727
1836
    {NULL, 0, 0, NULL}
1728
1837
};
1729
1838
 
1761
1870
 
1762
1871
    if (virDomainGetInfo(dom, &info) == 0) {
1763
1872
        vshPrint(ctl, "%-15s %s\n", _("State:"),
1764
 
                 N_(vshDomainStateToString(info.state)));
 
1873
                 _(vshDomainStateToString(info.state)));
1765
1874
 
1766
1875
        vshPrint(ctl, "%-15s %d\n", _("CPU(s):"), info.nrVirtCpu);
1767
1876
 
1825
1934
 * "domjobinfo" command
1826
1935
 */
1827
1936
static const vshCmdInfo info_domjobinfo[] = {
1828
 
    {"help", gettext_noop("domain job information")},
1829
 
    {"desc", gettext_noop("Returns information about jobs running on a domain.")},
 
1937
    {"help", N_("domain job information")},
 
1938
    {"desc", N_("Returns information about jobs running on a domain.")},
1830
1939
    {NULL, NULL}
1831
1940
};
1832
1941
 
1833
1942
static const vshCmdOptDef opts_domjobinfo[] = {
1834
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
 
1943
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
1835
1944
    {NULL, 0, 0, NULL}
1836
1945
};
1837
1946
 
1841
1950
{
1842
1951
    virDomainJobInfo info;
1843
1952
    virDomainPtr dom;
1844
 
    int ret = TRUE, autostart;
1845
 
    unsigned int id;
1846
 
    char *str, uuid[VIR_UUID_STRING_BUFLEN];
 
1953
    int ret = TRUE;
1847
1954
 
1848
1955
    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
1849
1956
        return FALSE;
1910
2017
 * "domjobabort" command
1911
2018
 */
1912
2019
static const vshCmdInfo info_domjobabort[] = {
1913
 
    {"help", gettext_noop("abort active domain job")},
1914
 
    {"desc", gettext_noop("Aborts the currently running domain job")},
 
2020
    {"help", N_("abort active domain job")},
 
2021
    {"desc", N_("Aborts the currently running domain job")},
1915
2022
    {NULL, NULL}
1916
2023
};
1917
2024
 
1918
2025
static const vshCmdOptDef opts_domjobabort[] = {
1919
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
 
2026
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
1920
2027
    {NULL, 0, 0, NULL}
1921
2028
};
1922
2029
 
1925
2032
{
1926
2033
    virDomainPtr dom;
1927
2034
    int ret = TRUE;
1928
 
    unsigned int id;
1929
 
    char *str, uuid[VIR_UUID_STRING_BUFLEN];
1930
2035
 
1931
2036
    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
1932
2037
        return FALSE;
1937
2042
    if (virDomainAbortJob(dom) < 0)
1938
2043
        ret = FALSE;
1939
2044
 
1940
 
cleanup:
1941
2045
    virDomainFree(dom);
1942
2046
    return ret;
1943
2047
}
1946
2050
 * "freecell" command
1947
2051
 */
1948
2052
static const vshCmdInfo info_freecell[] = {
1949
 
    {"help", gettext_noop("NUMA free memory")},
1950
 
    {"desc", gettext_noop("display available free memory for the NUMA cell.")},
 
2053
    {"help", N_("NUMA free memory")},
 
2054
    {"desc", N_("display available free memory for the NUMA cell.")},
1951
2055
    {NULL, NULL}
1952
2056
};
1953
2057
 
1954
2058
static const vshCmdOptDef opts_freecell[] = {
1955
 
    {"cellno", VSH_OT_DATA, 0, gettext_noop("NUMA cell number")},
 
2059
    {"cellno", VSH_OT_DATA, 0, N_("NUMA cell number")},
1956
2060
    {NULL, 0, 0, NULL}
1957
2061
};
1958
2062
 
1989
2093
 * "vcpuinfo" command
1990
2094
 */
1991
2095
static const vshCmdInfo info_vcpuinfo[] = {
1992
 
    {"help", gettext_noop("domain vcpu information")},
1993
 
    {"desc", gettext_noop("Returns basic information about the domain virtual CPUs.")},
 
2096
    {"help", N_("domain vcpu information")},
 
2097
    {"desc", N_("Returns basic information about the domain virtual CPUs.")},
1994
2098
    {NULL, NULL}
1995
2099
};
1996
2100
 
1997
2101
static const vshCmdOptDef opts_vcpuinfo[] = {
1998
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
 
2102
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
1999
2103
    {NULL, 0, 0, NULL}
2000
2104
};
2001
2105
 
2040
2144
            vshPrint(ctl, "%-15s %d\n", _("VCPU:"), n);
2041
2145
            vshPrint(ctl, "%-15s %d\n", _("CPU:"), cpuinfo[n].cpu);
2042
2146
            vshPrint(ctl, "%-15s %s\n", _("State:"),
2043
 
                     N_(vshDomainVcpuStateToString(cpuinfo[n].state)));
 
2147
                     _(vshDomainVcpuStateToString(cpuinfo[n].state)));
2044
2148
            if (cpuinfo[n].cpuTime != 0) {
2045
2149
                double cpuUsed = cpuinfo[n].cpuTime;
2046
2150
 
2075
2179
 * "vcpupin" command
2076
2180
 */
2077
2181
static const vshCmdInfo info_vcpupin[] = {
2078
 
    {"help", gettext_noop("control domain vcpu affinity")},
2079
 
    {"desc", gettext_noop("Pin domain VCPUs to host physical CPUs.")},
 
2182
    {"help", N_("control domain vcpu affinity")},
 
2183
    {"desc", N_("Pin domain VCPUs to host physical CPUs.")},
2080
2184
    {NULL, NULL}
2081
2185
};
2082
2186
 
2083
2187
static const vshCmdOptDef opts_vcpupin[] = {
2084
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
2085
 
    {"vcpu", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("vcpu number")},
2086
 
    {"cpulist", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("host cpu number(s) (comma separated)")},
 
2188
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
2189
    {"vcpu", VSH_OT_DATA, VSH_OFLAG_REQ, N_("vcpu number")},
 
2190
    {"cpulist", VSH_OT_DATA, VSH_OFLAG_REQ, N_("host cpu number(s) (comma separated)")},
2087
2191
    {NULL, 0, 0, NULL}
2088
2192
};
2089
2193
 
2212
2316
 * "setvcpus" command
2213
2317
 */
2214
2318
static const vshCmdInfo info_setvcpus[] = {
2215
 
    {"help", gettext_noop("change number of virtual CPUs")},
2216
 
    {"desc", gettext_noop("Change the number of virtual CPUs in the guest domain.")},
 
2319
    {"help", N_("change number of virtual CPUs")},
 
2320
    {"desc", N_("Change the number of virtual CPUs in the guest domain.")},
2217
2321
    {NULL, NULL}
2218
2322
};
2219
2323
 
2220
2324
static const vshCmdOptDef opts_setvcpus[] = {
2221
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
2222
 
    {"count", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("number of virtual CPUs")},
 
2325
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
2326
    {"count", VSH_OT_DATA, VSH_OFLAG_REQ, N_("number of virtual CPUs")},
2223
2327
    {NULL, 0, 0, NULL}
2224
2328
};
2225
2329
 
2268
2372
 * "setmemory" command
2269
2373
 */
2270
2374
static const vshCmdInfo info_setmem[] = {
2271
 
    {"help", gettext_noop("change memory allocation")},
2272
 
    {"desc", gettext_noop("Change the current memory allocation in the guest domain.")},
 
2375
    {"help", N_("change memory allocation")},
 
2376
    {"desc", N_("Change the current memory allocation in the guest domain.")},
2273
2377
    {NULL, NULL}
2274
2378
};
2275
2379
 
2276
2380
static const vshCmdOptDef opts_setmem[] = {
2277
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
2278
 
    {"kilobytes", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("number of kilobytes of memory")},
 
2381
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
2382
    {"kilobytes", VSH_OT_DATA, VSH_OFLAG_REQ, N_("number of kilobytes of memory")},
2279
2383
    {NULL, 0, 0, NULL}
2280
2384
};
2281
2385
 
2308
2412
 
2309
2413
    if (kilobytes > info.maxMem) {
2310
2414
        virDomainFree(dom);
2311
 
        vshError(ctl, _("Invalid value of %d for memory size"), kilobytes);
 
2415
        vshError(ctl, _("Requested memory size %d kb is larger than maximum of %lu kb"),
 
2416
                 kilobytes, info.maxMem);
2312
2417
        return FALSE;
2313
2418
    }
2314
2419
 
2324
2429
 * "setmaxmem" command
2325
2430
 */
2326
2431
static const vshCmdInfo info_setmaxmem[] = {
2327
 
    {"help", gettext_noop("change maximum memory limit")},
2328
 
    {"desc", gettext_noop("Change the maximum memory allocation limit in the guest domain.")},
 
2432
    {"help", N_("change maximum memory limit")},
 
2433
    {"desc", N_("Change the maximum memory allocation limit in the guest domain.")},
2329
2434
    {NULL, NULL}
2330
2435
};
2331
2436
 
2332
2437
static const vshCmdOptDef opts_setmaxmem[] = {
2333
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
2334
 
    {"kilobytes", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("maximum memory limit in kilobytes")},
 
2438
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
2439
    {"kilobytes", VSH_OT_DATA, VSH_OFLAG_REQ, N_("maximum memory limit in kilobytes")},
2335
2440
    {NULL, 0, 0, NULL}
2336
2441
};
2337
2442
 
2383
2488
 * "nodeinfo" command
2384
2489
 */
2385
2490
static const vshCmdInfo info_nodeinfo[] = {
2386
 
    {"help", gettext_noop("node information")},
2387
 
    {"desc", gettext_noop("Returns basic information about the node.")},
 
2491
    {"help", N_("node information")},
 
2492
    {"desc", N_("Returns basic information about the node.")},
2388
2493
    {NULL, NULL}
2389
2494
};
2390
2495
 
2416
2521
 * "capabilities" command
2417
2522
 */
2418
2523
static const vshCmdInfo info_capabilities[] = {
2419
 
    {"help", gettext_noop("capabilities")},
2420
 
    {"desc", gettext_noop("Returns capabilities of hypervisor/driver.")},
 
2524
    {"help", N_("capabilities")},
 
2525
    {"desc", N_("Returns capabilities of hypervisor/driver.")},
2421
2526
    {NULL, NULL}
2422
2527
};
2423
2528
 
2443
2548
 * "dumpxml" command
2444
2549
 */
2445
2550
static const vshCmdInfo info_dumpxml[] = {
2446
 
    {"help", gettext_noop("domain information in XML")},
2447
 
    {"desc", gettext_noop("Output the domain information as an XML dump to stdout.")},
 
2551
    {"help", N_("domain information in XML")},
 
2552
    {"desc", N_("Output the domain information as an XML dump to stdout.")},
2448
2553
    {NULL, NULL}
2449
2554
};
2450
2555
 
2451
2556
static const vshCmdOptDef opts_dumpxml[] = {
2452
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
2453
 
    {"inactive", VSH_OT_BOOL, 0, gettext_noop("show inactive defined XML")},
2454
 
    {"security-info", VSH_OT_BOOL, 0, gettext_noop("include security sensitive information in XML dump")},
 
2557
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
2558
    {"inactive", VSH_OT_BOOL, 0, N_("show inactive defined XML")},
 
2559
    {"security-info", VSH_OT_BOOL, 0, N_("include security sensitive information in XML dump")},
 
2560
    {"update-cpu", VSH_OT_BOOL, 0, N_("update guest CPU according to host CPU")},
2455
2561
    {NULL, 0, 0, NULL}
2456
2562
};
2457
2563
 
2464
2570
    int flags = 0;
2465
2571
    int inactive = vshCommandOptBool(cmd, "inactive");
2466
2572
    int secure = vshCommandOptBool(cmd, "security-info");
 
2573
    int update = vshCommandOptBool(cmd, "update-cpu");
2467
2574
 
2468
2575
    if (inactive)
2469
2576
        flags |= VIR_DOMAIN_XML_INACTIVE;
2470
2577
    if (secure)
2471
2578
        flags |= VIR_DOMAIN_XML_SECURE;
 
2579
    if (update)
 
2580
        flags |= VIR_DOMAIN_XML_UPDATE_CPU;
2472
2581
 
2473
2582
    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
2474
2583
        return FALSE;
2492
2601
 * "domxml-from-native" command
2493
2602
 */
2494
2603
static const vshCmdInfo info_domxmlfromnative[] = {
2495
 
    {"help", gettext_noop("Convert native config to domain XML")},
2496
 
    {"desc", gettext_noop("Convert native guest configuration format to domain XML format.")},
 
2604
    {"help", N_("Convert native config to domain XML")},
 
2605
    {"desc", N_("Convert native guest configuration format to domain XML format.")},
2497
2606
    {NULL, NULL}
2498
2607
};
2499
2608
 
2500
2609
static const vshCmdOptDef opts_domxmlfromnative[] = {
2501
 
    {"format", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("source config data format")},
2502
 
    {"config", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("config data file to import from")},
 
2610
    {"format", VSH_OT_DATA, VSH_OFLAG_REQ, N_("source config data format")},
 
2611
    {"config", VSH_OT_DATA, VSH_OFLAG_REQ, N_("config data file to import from")},
2503
2612
    {NULL, 0, 0, NULL}
2504
2613
};
2505
2614
 
2519
2628
    format = vshCommandOptString(cmd, "format", NULL);
2520
2629
    configFile = vshCommandOptString(cmd, "config", NULL);
2521
2630
 
2522
 
    if (virFileReadAll(configFile, 1024*1024, &configData) < 0) {
 
2631
    if (virFileReadAll(configFile, 1024*1024, &configData) < 0)
2523
2632
        return FALSE;
2524
 
    }
2525
2633
 
2526
2634
    xmlData = virConnectDomainXMLFromNative(ctl->conn, format, configData, flags);
2527
2635
    if (xmlData != NULL) {
2538
2646
 * "domxml-to-native" command
2539
2647
 */
2540
2648
static const vshCmdInfo info_domxmltonative[] = {
2541
 
    {"help", gettext_noop("Convert domain XML to native config")},
2542
 
    {"desc", gettext_noop("Convert domain XML config to a native guest configuration format.")},
 
2649
    {"help", N_("Convert domain XML to native config")},
 
2650
    {"desc", N_("Convert domain XML config to a native guest configuration format.")},
2543
2651
    {NULL, NULL}
2544
2652
};
2545
2653
 
2546
2654
static const vshCmdOptDef opts_domxmltonative[] = {
2547
 
    {"format", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("target config data type format")},
2548
 
    {"xml", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("xml data file to export from")},
 
2655
    {"format", VSH_OT_DATA, VSH_OFLAG_REQ, N_("target config data type format")},
 
2656
    {"xml", VSH_OT_DATA, VSH_OFLAG_REQ, N_("xml data file to export from")},
2549
2657
    {NULL, 0, 0, NULL}
2550
2658
};
2551
2659
 
2565
2673
    format = vshCommandOptString(cmd, "format", NULL);
2566
2674
    xmlFile = vshCommandOptString(cmd, "xml", NULL);
2567
2675
 
2568
 
    if (virFileReadAll(xmlFile, 1024*1024, &xmlData) < 0) {
 
2676
    if (virFileReadAll(xmlFile, 1024*1024, &xmlData) < 0)
2569
2677
        return FALSE;
2570
 
    }
2571
2678
 
2572
2679
    configData = virConnectDomainXMLToNative(ctl->conn, format, xmlData, flags);
2573
2680
    if (configData != NULL) {
2584
2691
 * "domname" command
2585
2692
 */
2586
2693
static const vshCmdInfo info_domname[] = {
2587
 
    {"help", gettext_noop("convert a domain id or UUID to domain name")},
 
2694
    {"help", N_("convert a domain id or UUID to domain name")},
2588
2695
    {"desc", ""},
2589
2696
    {NULL, NULL}
2590
2697
};
2591
2698
 
2592
2699
static const vshCmdOptDef opts_domname[] = {
2593
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain id or uuid")},
 
2700
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain id or uuid")},
2594
2701
    {NULL, 0, 0, NULL}
2595
2702
};
2596
2703
 
2614
2721
 * "domid" command
2615
2722
 */
2616
2723
static const vshCmdInfo info_domid[] = {
2617
 
    {"help", gettext_noop("convert a domain name or UUID to domain id")},
 
2724
    {"help", N_("convert a domain name or UUID to domain id")},
2618
2725
    {"desc", ""},
2619
2726
    {NULL, NULL}
2620
2727
};
2621
2728
 
2622
2729
static const vshCmdOptDef opts_domid[] = {
2623
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name or uuid")},
 
2730
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name or uuid")},
2624
2731
    {NULL, 0, 0, NULL}
2625
2732
};
2626
2733
 
2649
2756
 * "domuuid" command
2650
2757
 */
2651
2758
static const vshCmdInfo info_domuuid[] = {
2652
 
    {"help", gettext_noop("convert a domain name or id to domain UUID")},
 
2759
    {"help", N_("convert a domain name or id to domain UUID")},
2653
2760
    {"desc", ""},
2654
2761
    {NULL, NULL}
2655
2762
};
2656
2763
 
2657
2764
static const vshCmdOptDef opts_domuuid[] = {
2658
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain id or name")},
 
2765
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain id or name")},
2659
2766
    {NULL, 0, 0, NULL}
2660
2767
};
2661
2768
 
2684
2791
 * "migrate" command
2685
2792
 */
2686
2793
static const vshCmdInfo info_migrate[] = {
2687
 
    {"help", gettext_noop("migrate domain to another host")},
2688
 
    {"desc", gettext_noop("Migrate domain to another host.  Add --live for live migration.")},
 
2794
    {"help", N_("migrate domain to another host")},
 
2795
    {"desc", N_("Migrate domain to another host.  Add --live for live migration.")},
2689
2796
    {NULL, NULL}
2690
2797
};
2691
2798
 
2692
2799
static const vshCmdOptDef opts_migrate[] = {
2693
 
    {"live", VSH_OT_BOOL, 0, gettext_noop("live migration")},
2694
 
    {"p2p", VSH_OT_BOOL, 0, gettext_noop("peer-2-peer migration")},
2695
 
    {"direct", VSH_OT_BOOL, 0, gettext_noop("direct migration")},
2696
 
    {"tunnelled", VSH_OT_BOOL, 0, gettext_noop("tunnelled migration")},
2697
 
    {"persistent", VSH_OT_BOOL, 0, gettext_noop("persist VM on destination")},
2698
 
    {"undefinesource", VSH_OT_BOOL, 0, gettext_noop("undefine VM on source")},
2699
 
    {"suspend", VSH_OT_BOOL, 0, gettext_noop("do not restart the domain on the destination host")},
2700
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
2701
 
    {"desturi", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("connection URI of the destination host")},
2702
 
    {"migrateuri", VSH_OT_DATA, 0, gettext_noop("migration URI, usually can be omitted")},
2703
 
    {"dname", VSH_OT_DATA, 0, gettext_noop("rename to new name during migration (if supported)")},
 
2800
    {"live", VSH_OT_BOOL, 0, N_("live migration")},
 
2801
    {"p2p", VSH_OT_BOOL, 0, N_("peer-2-peer migration")},
 
2802
    {"direct", VSH_OT_BOOL, 0, N_("direct migration")},
 
2803
    {"tunnelled", VSH_OT_BOOL, 0, N_("tunnelled migration")},
 
2804
    {"persistent", VSH_OT_BOOL, 0, N_("persist VM on destination")},
 
2805
    {"undefinesource", VSH_OT_BOOL, 0, N_("undefine VM on source")},
 
2806
    {"suspend", VSH_OT_BOOL, 0, N_("do not restart the domain on the destination host")},
 
2807
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
2808
    {"desturi", VSH_OT_DATA, VSH_OFLAG_REQ, N_("connection URI of the destination host")},
 
2809
    {"migrateuri", VSH_OT_DATA, 0, N_("migration URI, usually can be omitted")},
 
2810
    {"dname", VSH_OT_DATA, 0, N_("rename to new name during migration (if supported)")},
2704
2811
    {NULL, 0, 0, NULL}
2705
2812
};
2706
2813
 
2778
2885
}
2779
2886
 
2780
2887
/*
 
2888
 * "migrate-setmaxdowntime" command
 
2889
 */
 
2890
static const vshCmdInfo info_migrate_setmaxdowntime[] = {
 
2891
    {"help", N_("set maximum tolerable downtime")},
 
2892
    {"desc", N_("Set maximum tolerable downtime of a domain which is being live-migrated to another host.")},
 
2893
    {NULL, NULL}
 
2894
};
 
2895
 
 
2896
static const vshCmdOptDef opts_migrate_setmaxdowntime[] = {
 
2897
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
2898
    {"downtime", VSH_OT_DATA, VSH_OFLAG_REQ, N_("maximum tolerable downtime (in milliseconds) for migration")},
 
2899
    {NULL, 0, 0, NULL}
 
2900
};
 
2901
 
 
2902
static int
 
2903
cmdMigrateSetMaxDowntime(vshControl *ctl, const vshCmd *cmd)
 
2904
{
 
2905
    virDomainPtr dom = NULL;
 
2906
    long long downtime;
 
2907
    int found;
 
2908
    int ret = FALSE;
 
2909
 
 
2910
    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
 
2911
        return FALSE;
 
2912
 
 
2913
    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
 
2914
        return FALSE;
 
2915
 
 
2916
    downtime = vshCommandOptLongLong(cmd, "downtime", &found);
 
2917
    if (!found || downtime < 1) {
 
2918
        vshError(ctl, "%s", _("migrate: Invalid downtime"));
 
2919
        goto done;
 
2920
    }
 
2921
 
 
2922
    if (virDomainMigrateSetMaxDowntime(dom, downtime, 0))
 
2923
        goto done;
 
2924
 
 
2925
    ret = TRUE;
 
2926
 
 
2927
done:
 
2928
    virDomainFree(dom);
 
2929
    return ret;
 
2930
}
 
2931
 
 
2932
/*
2781
2933
 * "net-autostart" command
2782
2934
 */
2783
2935
static const vshCmdInfo info_network_autostart[] = {
2784
 
    {"help", gettext_noop("autostart a network")},
 
2936
    {"help", N_("autostart a network")},
2785
2937
    {"desc",
2786
 
     gettext_noop("Configure a network to be automatically started at boot.")},
 
2938
     N_("Configure a network to be automatically started at boot.")},
2787
2939
    {NULL, NULL}
2788
2940
};
2789
2941
 
2790
2942
static const vshCmdOptDef opts_network_autostart[] = {
2791
 
    {"network",  VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("network name or uuid")},
2792
 
    {"disable", VSH_OT_BOOL, 0, gettext_noop("disable autostarting")},
 
2943
    {"network",  VSH_OT_DATA, VSH_OFLAG_REQ, N_("network name or uuid")},
 
2944
    {"disable", VSH_OT_BOOL, 0, N_("disable autostarting")},
2793
2945
    {NULL, 0, 0, NULL}
2794
2946
};
2795
2947
 
2830
2982
 * "net-create" command
2831
2983
 */
2832
2984
static const vshCmdInfo info_network_create[] = {
2833
 
    {"help", gettext_noop("create a network from an XML file")},
2834
 
    {"desc", gettext_noop("Create a network.")},
 
2985
    {"help", N_("create a network from an XML file")},
 
2986
    {"desc", N_("Create a network.")},
2835
2987
    {NULL, NULL}
2836
2988
};
2837
2989
 
2838
2990
static const vshCmdOptDef opts_network_create[] = {
2839
 
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("file containing an XML network description")},
 
2991
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML network description")},
2840
2992
    {NULL, 0, 0, NULL}
2841
2993
};
2842
2994
 
2878
3030
 * "net-define" command
2879
3031
 */
2880
3032
static const vshCmdInfo info_network_define[] = {
2881
 
    {"help", gettext_noop("define (but don't start) a network from an XML file")},
2882
 
    {"desc", gettext_noop("Define a network.")},
 
3033
    {"help", N_("define (but don't start) a network from an XML file")},
 
3034
    {"desc", N_("Define a network.")},
2883
3035
    {NULL, NULL}
2884
3036
};
2885
3037
 
2886
3038
static const vshCmdOptDef opts_network_define[] = {
2887
 
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("file containing an XML network description")},
 
3039
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML network description")},
2888
3040
    {NULL, 0, 0, NULL}
2889
3041
};
2890
3042
 
2926
3078
 * "net-destroy" command
2927
3079
 */
2928
3080
static const vshCmdInfo info_network_destroy[] = {
2929
 
    {"help", gettext_noop("destroy a network")},
2930
 
    {"desc", gettext_noop("Destroy a given network.")},
 
3081
    {"help", N_("destroy a network")},
 
3082
    {"desc", N_("Destroy a given network.")},
2931
3083
    {NULL, NULL}
2932
3084
};
2933
3085
 
2934
3086
static const vshCmdOptDef opts_network_destroy[] = {
2935
 
    {"network", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("network name, id or uuid")},
 
3087
    {"network", VSH_OT_DATA, VSH_OFLAG_REQ, N_("network name, id or uuid")},
2936
3088
    {NULL, 0, 0, NULL}
2937
3089
};
2938
3090
 
2965
3117
 * "net-dumpxml" command
2966
3118
 */
2967
3119
static const vshCmdInfo info_network_dumpxml[] = {
2968
 
    {"help", gettext_noop("network information in XML")},
2969
 
    {"desc", gettext_noop("Output the network information as an XML dump to stdout.")},
 
3120
    {"help", N_("network information in XML")},
 
3121
    {"desc", N_("Output the network information as an XML dump to stdout.")},
2970
3122
    {NULL, NULL}
2971
3123
};
2972
3124
 
2973
3125
static const vshCmdOptDef opts_network_dumpxml[] = {
2974
 
    {"network", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("network name, id or uuid")},
 
3126
    {"network", VSH_OT_DATA, VSH_OFLAG_REQ, N_("network name, id or uuid")},
2975
3127
    {NULL, 0, 0, NULL}
2976
3128
};
2977
3129
 
3005
3157
 * "iface-edit" command
3006
3158
 */
3007
3159
static const vshCmdInfo info_interface_edit[] = {
3008
 
    {"help", gettext_noop("edit XML configuration for a physical host interface")},
3009
 
    {"desc", gettext_noop("Edit the XML configuration for a physical host interface.")},
 
3160
    {"help", N_("edit XML configuration for a physical host interface")},
 
3161
    {"desc", N_("Edit the XML configuration for a physical host interface.")},
3010
3162
    {NULL, NULL}
3011
3163
};
3012
3164
 
3013
3165
static const vshCmdOptDef opts_interface_edit[] = {
3014
 
    {"interface", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("interface name or MAC address")},
 
3166
    {"interface", VSH_OT_DATA, VSH_OFLAG_REQ, N_("interface name or MAC address")},
3015
3167
    {NULL, 0, 0, NULL}
3016
3168
};
3017
3169
 
3105
3257
 * "net-list" command
3106
3258
 */
3107
3259
static const vshCmdInfo info_network_list[] = {
3108
 
    {"help", gettext_noop("list networks")},
3109
 
    {"desc", gettext_noop("Returns list of networks.")},
 
3260
    {"help", N_("list networks")},
 
3261
    {"desc", N_("Returns list of networks.")},
3110
3262
    {NULL, NULL}
3111
3263
};
3112
3264
 
3113
3265
static const vshCmdOptDef opts_network_list[] = {
3114
 
    {"inactive", VSH_OT_BOOL, 0, gettext_noop("list inactive networks")},
3115
 
    {"all", VSH_OT_BOOL, 0, gettext_noop("list inactive & active networks")},
 
3266
    {"inactive", VSH_OT_BOOL, 0, N_("list inactive networks")},
 
3267
    {"all", VSH_OT_BOOL, 0, N_("list inactive & active networks")},
3116
3268
    {NULL, 0, 0, NULL}
3117
3269
};
3118
3270
 
3232
3384
 * "net-name" command
3233
3385
 */
3234
3386
static const vshCmdInfo info_network_name[] = {
3235
 
    {"help", gettext_noop("convert a network UUID to network name")},
 
3387
    {"help", N_("convert a network UUID to network name")},
3236
3388
    {"desc", ""},
3237
3389
    {NULL, NULL}
3238
3390
};
3239
3391
 
3240
3392
static const vshCmdOptDef opts_network_name[] = {
3241
 
    {"network", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("network uuid")},
 
3393
    {"network", VSH_OT_DATA, VSH_OFLAG_REQ, N_("network uuid")},
3242
3394
    {NULL, 0, 0, NULL}
3243
3395
};
3244
3396
 
3263
3415
 * "net-start" command
3264
3416
 */
3265
3417
static const vshCmdInfo info_network_start[] = {
3266
 
    {"help", gettext_noop("start a (previously defined) inactive network")},
3267
 
    {"desc", gettext_noop("Start a network.")},
 
3418
    {"help", N_("start a (previously defined) inactive network")},
 
3419
    {"desc", N_("Start a network.")},
3268
3420
    {NULL, NULL}
3269
3421
};
3270
3422
 
3271
3423
static const vshCmdOptDef opts_network_start[] = {
3272
 
    {"network", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("name of the inactive network")},
 
3424
    {"network", VSH_OT_DATA, VSH_OFLAG_REQ, N_("name of the inactive network")},
3273
3425
    {NULL, 0, 0, NULL}
3274
3426
};
3275
3427
 
3302
3454
 * "net-undefine" command
3303
3455
 */
3304
3456
static const vshCmdInfo info_network_undefine[] = {
3305
 
    {"help", gettext_noop("undefine an inactive network")},
3306
 
    {"desc", gettext_noop("Undefine the configuration for an inactive network.")},
 
3457
    {"help", N_("undefine an inactive network")},
 
3458
    {"desc", N_("Undefine the configuration for an inactive network.")},
3307
3459
    {NULL, NULL}
3308
3460
};
3309
3461
 
3310
3462
static const vshCmdOptDef opts_network_undefine[] = {
3311
 
    {"network", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("network name or uuid")},
 
3463
    {"network", VSH_OT_DATA, VSH_OFLAG_REQ, N_("network name or uuid")},
3312
3464
    {NULL, 0, 0, NULL}
3313
3465
};
3314
3466
 
3341
3493
 * "net-uuid" command
3342
3494
 */
3343
3495
static const vshCmdInfo info_network_uuid[] = {
3344
 
    {"help", gettext_noop("convert a network name to network UUID")},
 
3496
    {"help", N_("convert a network name to network UUID")},
3345
3497
    {"desc", ""},
3346
3498
    {NULL, NULL}
3347
3499
};
3348
3500
 
3349
3501
static const vshCmdOptDef opts_network_uuid[] = {
3350
 
    {"network", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("network name")},
 
3502
    {"network", VSH_OT_DATA, VSH_OFLAG_REQ, N_("network name")},
3351
3503
    {NULL, 0, 0, NULL}
3352
3504
};
3353
3505
 
3379
3531
 * "iface-list" command
3380
3532
 */
3381
3533
static const vshCmdInfo info_interface_list[] = {
3382
 
    {"help", gettext_noop("list physical host interfaces")},
3383
 
    {"desc", gettext_noop("Returns list of physical host interfaces.")},
 
3534
    {"help", N_("list physical host interfaces")},
 
3535
    {"desc", N_("Returns list of physical host interfaces.")},
3384
3536
    {NULL, NULL}
3385
3537
};
3386
3538
 
3387
3539
static const vshCmdOptDef opts_interface_list[] = {
3388
 
    {"inactive", VSH_OT_BOOL, 0, gettext_noop("list inactive interfaces")},
3389
 
    {"all", VSH_OT_BOOL, 0, gettext_noop("list inactive & active interfaces")},
 
3540
    {"inactive", VSH_OT_BOOL, 0, N_("list inactive interfaces")},
 
3541
    {"all", VSH_OT_BOOL, 0, N_("list inactive & active interfaces")},
3390
3542
    {NULL, 0, 0, NULL}
3391
3543
};
3392
3544
static int
3491
3643
 * "iface-name" command
3492
3644
 */
3493
3645
static const vshCmdInfo info_interface_name[] = {
3494
 
    {"help", gettext_noop("convert an interface MAC address to interface name")},
 
3646
    {"help", N_("convert an interface MAC address to interface name")},
3495
3647
    {"desc", ""},
3496
3648
    {NULL, NULL}
3497
3649
};
3498
3650
 
3499
3651
static const vshCmdOptDef opts_interface_name[] = {
3500
 
    {"interface", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("interface mac")},
 
3652
    {"interface", VSH_OT_DATA, VSH_OFLAG_REQ, N_("interface mac")},
3501
3653
    {NULL, 0, 0, NULL}
3502
3654
};
3503
3655
 
3521
3673
 * "iface-mac" command
3522
3674
 */
3523
3675
static const vshCmdInfo info_interface_mac[] = {
3524
 
    {"help", gettext_noop("convert an interface name to interface MAC address")},
 
3676
    {"help", N_("convert an interface name to interface MAC address")},
3525
3677
    {"desc", ""},
3526
3678
    {NULL, NULL}
3527
3679
};
3528
3680
 
3529
3681
static const vshCmdOptDef opts_interface_mac[] = {
3530
 
    {"interface", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("interface name")},
 
3682
    {"interface", VSH_OT_DATA, VSH_OFLAG_REQ, N_("interface name")},
3531
3683
    {NULL, 0, 0, NULL}
3532
3684
};
3533
3685
 
3551
3703
 * "iface-dumpxml" command
3552
3704
 */
3553
3705
static const vshCmdInfo info_interface_dumpxml[] = {
3554
 
    {"help", gettext_noop("interface information in XML")},
3555
 
    {"desc", gettext_noop("Output the physical host interface information as an XML dump to stdout.")},
 
3706
    {"help", N_("interface information in XML")},
 
3707
    {"desc", N_("Output the physical host interface information as an XML dump to stdout.")},
3556
3708
    {NULL, NULL}
3557
3709
};
3558
3710
 
3559
3711
static const vshCmdOptDef opts_interface_dumpxml[] = {
3560
 
    {"interface", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("interface name or MAC address")},
3561
 
    {"inactive", VSH_OT_BOOL, 0, gettext_noop("show inactive defined XML")},
 
3712
    {"interface", VSH_OT_DATA, VSH_OFLAG_REQ, N_("interface name or MAC address")},
 
3713
    {"inactive", VSH_OT_BOOL, 0, N_("show inactive defined XML")},
3562
3714
    {NULL, 0, 0, NULL}
3563
3715
};
3564
3716
 
3596
3748
 * "iface-define" command
3597
3749
 */
3598
3750
static const vshCmdInfo info_interface_define[] = {
3599
 
    {"help", gettext_noop("define (but don't start) a physical host interface from an XML file")},
3600
 
    {"desc", gettext_noop("Define a physical host interface.")},
 
3751
    {"help", N_("define (but don't start) a physical host interface from an XML file")},
 
3752
    {"desc", N_("Define a physical host interface.")},
3601
3753
    {NULL, NULL}
3602
3754
};
3603
3755
 
3604
3756
static const vshCmdOptDef opts_interface_define[] = {
3605
 
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("file containing an XML interface description")},
 
3757
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML interface description")},
3606
3758
    {NULL, 0, 0, NULL}
3607
3759
};
3608
3760
 
3643
3795
 * "iface-undefine" command
3644
3796
 */
3645
3797
static const vshCmdInfo info_interface_undefine[] = {
3646
 
    {"help", gettext_noop("undefine a physical host interface (remove it from configuration)")},
3647
 
    {"desc", gettext_noop("undefine an interface.")},
 
3798
    {"help", N_("undefine a physical host interface (remove it from configuration)")},
 
3799
    {"desc", N_("undefine an interface.")},
3648
3800
    {NULL, NULL}
3649
3801
};
3650
3802
 
3651
3803
static const vshCmdOptDef opts_interface_undefine[] = {
3652
 
    {"interface", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("interface name or MAC address")},
 
3804
    {"interface", VSH_OT_DATA, VSH_OFLAG_REQ, N_("interface name or MAC address")},
3653
3805
    {NULL, 0, 0, NULL}
3654
3806
};
3655
3807
 
3681
3833
 * "iface-start" command
3682
3834
 */
3683
3835
static const vshCmdInfo info_interface_start[] = {
3684
 
    {"help", gettext_noop("start a physical host interface (enable it / \"if-up\")")},
3685
 
    {"desc", gettext_noop("start a physical host interface.")},
 
3836
    {"help", N_("start a physical host interface (enable it / \"if-up\")")},
 
3837
    {"desc", N_("start a physical host interface.")},
3686
3838
    {NULL, NULL}
3687
3839
};
3688
3840
 
3689
3841
static const vshCmdOptDef opts_interface_start[] = {
3690
 
    {"interface", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("interface name or MAC address")},
 
3842
    {"interface", VSH_OT_DATA, VSH_OFLAG_REQ, N_("interface name or MAC address")},
3691
3843
    {NULL, 0, 0, NULL}
3692
3844
};
3693
3845
 
3719
3871
 * "iface-destroy" command
3720
3872
 */
3721
3873
static const vshCmdInfo info_interface_destroy[] = {
3722
 
    {"help", gettext_noop("destroy a physical host interface (disable it / \"if-down\")")},
3723
 
    {"desc", gettext_noop("destroy a physical host interface.")},
 
3874
    {"help", N_("destroy a physical host interface (disable it / \"if-down\")")},
 
3875
    {"desc", N_("destroy a physical host interface.")},
3724
3876
    {NULL, NULL}
3725
3877
};
3726
3878
 
3727
3879
static const vshCmdOptDef opts_interface_destroy[] = {
3728
 
    {"interface", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("interface name or MAC address")},
 
3880
    {"interface", VSH_OT_DATA, VSH_OFLAG_REQ, N_("interface name or MAC address")},
3729
3881
    {NULL, 0, 0, NULL}
3730
3882
};
3731
3883
 
3753
3905
    return ret;
3754
3906
}
3755
3907
 
 
3908
 
 
3909
/*
 
3910
 * "nwfilter-define" command
 
3911
 */
 
3912
static const vshCmdInfo info_nwfilter_define[] = {
 
3913
    {"help", N_("define or update a network filter from an XML file")},
 
3914
    {"desc", N_("Define a new network filter or update an existing one.")},
 
3915
    {NULL, NULL}
 
3916
};
 
3917
 
 
3918
static const vshCmdOptDef opts_nwfilter_define[] = {
 
3919
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML network filter description")},
 
3920
    {NULL, 0, 0, NULL}
 
3921
};
 
3922
 
 
3923
static int
 
3924
cmdNWFilterDefine(vshControl *ctl, const vshCmd *cmd)
 
3925
{
 
3926
    virNWFilterPtr nwfilter;
 
3927
    char *from;
 
3928
    int found;
 
3929
    int ret = TRUE;
 
3930
    char *buffer;
 
3931
 
 
3932
    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
 
3933
        return FALSE;
 
3934
 
 
3935
    from = vshCommandOptString(cmd, "file", &found);
 
3936
    if (!found)
 
3937
        return FALSE;
 
3938
 
 
3939
    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
 
3940
        return FALSE;
 
3941
 
 
3942
    nwfilter = virNWFilterDefineXML(ctl->conn, buffer);
 
3943
    VIR_FREE(buffer);
 
3944
 
 
3945
    if (nwfilter != NULL) {
 
3946
        vshPrint(ctl, _("Network filter %s defined from %s\n"),
 
3947
                 virNWFilterGetName(nwfilter), from);
 
3948
        virNWFilterFree(nwfilter);
 
3949
    } else {
 
3950
        vshError(ctl, _("Failed to define network filter from %s"), from);
 
3951
        ret = FALSE;
 
3952
    }
 
3953
    return ret;
 
3954
}
 
3955
 
 
3956
 
 
3957
/*
 
3958
 * "nwfilter-undefine" command
 
3959
 */
 
3960
static const vshCmdInfo info_nwfilter_undefine[] = {
 
3961
    {"help", N_("undefine a network filter")},
 
3962
    {"desc", N_("Undefine a given network filter.")},
 
3963
    {NULL, NULL}
 
3964
};
 
3965
 
 
3966
static const vshCmdOptDef opts_nwfilter_undefine[] = {
 
3967
    {"nwfilter", VSH_OT_DATA, VSH_OFLAG_REQ, N_("network filter name or uuid")},
 
3968
    {NULL, 0, 0, NULL}
 
3969
};
 
3970
 
 
3971
static int
 
3972
cmdNWFilterUndefine(vshControl *ctl, const vshCmd *cmd)
 
3973
{
 
3974
    virNWFilterPtr nwfilter;
 
3975
    int ret = TRUE;
 
3976
    char *name;
 
3977
 
 
3978
    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
 
3979
        return FALSE;
 
3980
 
 
3981
    if (!(nwfilter = vshCommandOptNWFilter(ctl, cmd, &name)))
 
3982
        return FALSE;
 
3983
 
 
3984
    if (virNWFilterUndefine(nwfilter) == 0) {
 
3985
        vshPrint(ctl, _("Network filter %s undefined\n"), name);
 
3986
    } else {
 
3987
        vshError(ctl, _("Failed to undefine network filter %s"), name);
 
3988
        ret = FALSE;
 
3989
    }
 
3990
 
 
3991
    virNWFilterFree(nwfilter);
 
3992
    return ret;
 
3993
}
 
3994
 
 
3995
 
 
3996
/*
 
3997
 * "nwfilter-dumpxml" command
 
3998
 */
 
3999
static const vshCmdInfo info_nwfilter_dumpxml[] = {
 
4000
    {"help", N_("network filter information in XML")},
 
4001
    {"desc", N_("Output the network filter information as an XML dump to stdout.")},
 
4002
    {NULL, NULL}
 
4003
};
 
4004
 
 
4005
static const vshCmdOptDef opts_nwfilter_dumpxml[] = {
 
4006
    {"nwfilter", VSH_OT_DATA, VSH_OFLAG_REQ, N_("network filter name or uuid")},
 
4007
    {NULL, 0, 0, NULL}
 
4008
};
 
4009
 
 
4010
static int
 
4011
cmdNWFilterDumpXML(vshControl *ctl, const vshCmd *cmd)
 
4012
{
 
4013
    virNWFilterPtr nwfilter;
 
4014
    int ret = TRUE;
 
4015
    char *dump;
 
4016
 
 
4017
    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
 
4018
        return FALSE;
 
4019
 
 
4020
    if (!(nwfilter = vshCommandOptNWFilter(ctl, cmd, NULL)))
 
4021
        return FALSE;
 
4022
 
 
4023
    dump = virNWFilterGetXMLDesc(nwfilter, 0);
 
4024
    if (dump != NULL) {
 
4025
        printf("%s", dump);
 
4026
        VIR_FREE(dump);
 
4027
    } else {
 
4028
        ret = FALSE;
 
4029
    }
 
4030
 
 
4031
    virNWFilterFree(nwfilter);
 
4032
    return ret;
 
4033
}
 
4034
 
 
4035
/*
 
4036
 * "nwfilter-list" command
 
4037
 */
 
4038
static const vshCmdInfo info_nwfilter_list[] = {
 
4039
    {"help", N_("list network filters")},
 
4040
    {"desc", N_("Returns list of network filters.")},
 
4041
    {NULL, NULL}
 
4042
};
 
4043
 
 
4044
static const vshCmdOptDef opts_nwfilter_list[] = {
 
4045
    {NULL, 0, 0, NULL}
 
4046
};
 
4047
 
 
4048
static int
 
4049
cmdNWFilterList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
 
4050
{
 
4051
    int numfilters, i;
 
4052
    char **names;
 
4053
    char uuid[VIR_UUID_STRING_BUFLEN];
 
4054
 
 
4055
    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
 
4056
        return FALSE;
 
4057
 
 
4058
    numfilters = virConnectNumOfNWFilters(ctl->conn);
 
4059
    if (numfilters < 0) {
 
4060
        vshError(ctl, "%s", _("Failed to list network filters"));
 
4061
        return FALSE;
 
4062
    }
 
4063
 
 
4064
    names = vshMalloc(ctl, sizeof(char *) * numfilters);
 
4065
 
 
4066
    if ((numfilters = virConnectListNWFilters(ctl->conn, names,
 
4067
                                              numfilters)) < 0) {
 
4068
        vshError(ctl, "%s", _("Failed to list network filters"));
 
4069
        VIR_FREE(names);
 
4070
        return FALSE;
 
4071
    }
 
4072
 
 
4073
    qsort(&names[0], numfilters, sizeof(char *), namesorter);
 
4074
 
 
4075
    vshPrintExtra(ctl, "%-36s  %-20s \n", _("UUID"), _("Name"));
 
4076
    vshPrintExtra(ctl,
 
4077
       "----------------------------------------------------------------\n");
 
4078
 
 
4079
    for (i = 0; i < numfilters; i++) {
 
4080
        virNWFilterPtr nwfilter =
 
4081
            virNWFilterLookupByName(ctl->conn, names[i]);
 
4082
 
 
4083
        /* this kind of work with networks is not atomic operation */
 
4084
        if (!nwfilter) {
 
4085
            VIR_FREE(names[i]);
 
4086
            continue;
 
4087
        }
 
4088
 
 
4089
        virNWFilterGetUUIDString(nwfilter, uuid);
 
4090
        vshPrint(ctl, "%-36s  %-20s\n",
 
4091
                 uuid,
 
4092
                 virNWFilterGetName(nwfilter));
 
4093
        virNWFilterFree(nwfilter);
 
4094
        VIR_FREE(names[i]);
 
4095
    }
 
4096
 
 
4097
    VIR_FREE(names);
 
4098
    return TRUE;
 
4099
}
 
4100
 
 
4101
 
 
4102
/*
 
4103
 * "nwfilter-edit" command
 
4104
 */
 
4105
static const vshCmdInfo info_nwfilter_edit[] = {
 
4106
    {"help", N_("edit XML configuration for a network filter")},
 
4107
    {"desc", N_("Edit the XML configuration for a network filter.")},
 
4108
    {NULL, NULL}
 
4109
};
 
4110
 
 
4111
static const vshCmdOptDef opts_nwfilter_edit[] = {
 
4112
    {"nwfilter", VSH_OT_DATA, VSH_OFLAG_REQ, N_("network filter name or uuid")},
 
4113
    {NULL, 0, 0, NULL}
 
4114
};
 
4115
 
 
4116
static int
 
4117
cmdNWFilterEdit (vshControl *ctl, const vshCmd *cmd)
 
4118
{
 
4119
    int ret = FALSE;
 
4120
    virNWFilterPtr nwfilter = NULL;
 
4121
    char *tmp = NULL;
 
4122
    char *doc = NULL;
 
4123
    char *doc_edited = NULL;
 
4124
    char *doc_reread = NULL;
 
4125
 
 
4126
    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
 
4127
        goto cleanup;
 
4128
 
 
4129
    nwfilter = vshCommandOptNWFilter (ctl, cmd, NULL);
 
4130
    if (nwfilter == NULL)
 
4131
        goto cleanup;
 
4132
 
 
4133
    /* Get the XML configuration of the interface. */
 
4134
    doc = virNWFilterGetXMLDesc (nwfilter, 0);
 
4135
    if (!doc)
 
4136
        goto cleanup;
 
4137
 
 
4138
    /* Create and open the temporary file. */
 
4139
    tmp = editWriteToTempFile (ctl, doc);
 
4140
    if (!tmp) goto cleanup;
 
4141
 
 
4142
    /* Start the editor. */
 
4143
    if (editFile (ctl, tmp) == -1) goto cleanup;
 
4144
 
 
4145
    /* Read back the edited file. */
 
4146
    doc_edited = editReadBackFile (ctl, tmp);
 
4147
    if (!doc_edited) goto cleanup;
 
4148
 
 
4149
    unlink (tmp);
 
4150
    tmp = NULL;
 
4151
 
 
4152
    /* Compare original XML with edited.  Has it changed at all? */
 
4153
    if (STREQ (doc, doc_edited)) {
 
4154
        vshPrint (ctl, _("Network filter %s XML configuration not changed.\n"),
 
4155
                  virNWFilterGetName (nwfilter));
 
4156
        ret = TRUE;
 
4157
        goto cleanup;
 
4158
    }
 
4159
 
 
4160
    /* Now re-read the network filter XML.  Did someone else change it while
 
4161
     * it was being edited?  This also catches problems such as us
 
4162
     * losing a connection or the interface going away.
 
4163
     */
 
4164
    doc_reread = virNWFilterGetXMLDesc (nwfilter, 0);
 
4165
    if (!doc_reread)
 
4166
        goto cleanup;
 
4167
 
 
4168
    if (STRNEQ (doc, doc_reread)) {
 
4169
        vshError(ctl, "%s",
 
4170
                 _("ERROR: the XML configuration was changed by another user"));
 
4171
        goto cleanup;
 
4172
    }
 
4173
 
 
4174
    /* Everything checks out, so redefine the interface. */
 
4175
    virNWFilterFree (nwfilter);
 
4176
    nwfilter = virNWFilterDefineXML (ctl->conn, doc_edited);
 
4177
    if (!nwfilter)
 
4178
        goto cleanup;
 
4179
 
 
4180
    vshPrint (ctl, _("Network filter %s XML configuration edited.\n"),
 
4181
              virNWFilterGetName(nwfilter));
 
4182
 
 
4183
    ret = TRUE;
 
4184
 
 
4185
cleanup:
 
4186
    if (nwfilter)
 
4187
        virNWFilterFree (nwfilter);
 
4188
 
 
4189
    VIR_FREE(doc);
 
4190
    VIR_FREE(doc_edited);
 
4191
    VIR_FREE(doc_reread);
 
4192
 
 
4193
    if (tmp) {
 
4194
        unlink (tmp);
 
4195
        VIR_FREE(tmp);
 
4196
    }
 
4197
 
 
4198
    return ret;
 
4199
}
 
4200
 
 
4201
 
3756
4202
/**************************************************************************/
3757
4203
/*
3758
4204
 * "pool-autostart" command
3759
4205
 */
3760
4206
static const vshCmdInfo info_pool_autostart[] = {
3761
 
    {"help", gettext_noop("autostart a pool")},
 
4207
    {"help", N_("autostart a pool")},
3762
4208
    {"desc",
3763
 
     gettext_noop("Configure a pool to be automatically started at boot.")},
 
4209
     N_("Configure a pool to be automatically started at boot.")},
3764
4210
    {NULL, NULL}
3765
4211
};
3766
4212
 
3767
4213
static const vshCmdOptDef opts_pool_autostart[] = {
3768
 
    {"pool",  VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("pool name or uuid")},
3769
 
    {"disable", VSH_OT_BOOL, 0, gettext_noop("disable autostarting")},
 
4214
    {"pool",  VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name or uuid")},
 
4215
    {"disable", VSH_OT_BOOL, 0, N_("disable autostarting")},
3770
4216
    {NULL, 0, 0, NULL}
3771
4217
};
3772
4218
 
3807
4253
 * "pool-create" command
3808
4254
 */
3809
4255
static const vshCmdInfo info_pool_create[] = {
3810
 
    {"help", gettext_noop("create a pool from an XML file")},
3811
 
    {"desc", gettext_noop("Create a pool.")},
 
4256
    {"help", N_("create a pool from an XML file")},
 
4257
    {"desc", N_("Create a pool.")},
3812
4258
    {NULL, NULL}
3813
4259
};
3814
4260
 
3815
4261
static const vshCmdOptDef opts_pool_create[] = {
3816
4262
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ,
3817
 
     gettext_noop("file containing an XML pool description")},
 
4263
     N_("file containing an XML pool description")},
3818
4264
    {NULL, 0, 0, NULL}
3819
4265
};
3820
4266
 
3856
4302
 * "nodedev-create" command
3857
4303
 */
3858
4304
static const vshCmdInfo info_node_device_create[] = {
3859
 
    {"help", gettext_noop("create a device defined "
 
4305
    {"help", N_("create a device defined "
3860
4306
                          "by an XML file on the node")},
3861
 
    {"desc", gettext_noop("Create a device on the node.  Note that this "
 
4307
    {"desc", N_("Create a device on the node.  Note that this "
3862
4308
                          "command creates devices on the physical host "
3863
4309
                          "that can then be assigned to a virtual machine.")},
3864
4310
    {NULL, NULL}
3866
4312
 
3867
4313
static const vshCmdOptDef opts_node_device_create[] = {
3868
4314
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ,
3869
 
     gettext_noop("file containing an XML description of the device")},
 
4315
     N_("file containing an XML description of the device")},
3870
4316
    {NULL, 0, 0, NULL}
3871
4317
};
3872
4318
 
3887
4333
        return FALSE;
3888
4334
    }
3889
4335
 
3890
 
    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
 
4336
    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
3891
4337
        return FALSE;
3892
 
    }
3893
4338
 
3894
4339
    dev = virNodeDeviceCreateXML(ctl->conn, buffer, 0);
3895
4340
    VIR_FREE(buffer);
3911
4356
 * "nodedev-destroy" command
3912
4357
 */
3913
4358
static const vshCmdInfo info_node_device_destroy[] = {
3914
 
    {"help", gettext_noop("destroy a device on the node")},
3915
 
    {"desc", gettext_noop("Destroy a device on the node.  Note that this "
 
4359
    {"help", N_("destroy a device on the node")},
 
4360
    {"desc", N_("Destroy a device on the node.  Note that this "
3916
4361
                          "command destroys devices on the physical host ")},
3917
4362
    {NULL, NULL}
3918
4363
};
3919
4364
 
3920
4365
static const vshCmdOptDef opts_node_device_destroy[] = {
3921
4366
    {"name", VSH_OT_DATA, VSH_OFLAG_REQ,
3922
 
     gettext_noop("name of the device to be destroyed")},
 
4367
     N_("name of the device to be destroyed")},
3923
4368
    {NULL, 0, 0, NULL}
3924
4369
};
3925
4370
 
3958
4403
 * XML Building helper for pool-define-as and pool-create-as
3959
4404
 */
3960
4405
static const vshCmdOptDef opts_pool_X_as[] = {
3961
 
    {"name", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("name of the pool")},
3962
 
    {"print-xml", VSH_OT_BOOL, 0, gettext_noop("print XML document, but don't define/create")},
3963
 
    {"type", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("type of the pool")},
3964
 
    {"source-host", VSH_OT_DATA, 0, gettext_noop("source-host for underlying storage")},
3965
 
    {"source-path", VSH_OT_DATA, 0, gettext_noop("source path for underlying storage")},
3966
 
    {"source-dev", VSH_OT_DATA, 0, gettext_noop("source device for underlying storage")},
3967
 
    {"source-name", VSH_OT_DATA, 0, gettext_noop("source name for underlying storage")},
3968
 
    {"target", VSH_OT_DATA, 0, gettext_noop("target for underlying storage")},
 
4406
    {"name", VSH_OT_DATA, VSH_OFLAG_REQ, N_("name of the pool")},
 
4407
    {"print-xml", VSH_OT_BOOL, 0, N_("print XML document, but don't define/create")},
 
4408
    {"type", VSH_OT_DATA, VSH_OFLAG_REQ, N_("type of the pool")},
 
4409
    {"source-host", VSH_OT_DATA, 0, N_("source-host for underlying storage")},
 
4410
    {"source-path", VSH_OT_DATA, 0, N_("source path for underlying storage")},
 
4411
    {"source-dev", VSH_OT_DATA, 0, N_("source device for underlying storage")},
 
4412
    {"source-name", VSH_OT_DATA, 0, N_("source name for underlying storage")},
 
4413
    {"target", VSH_OT_DATA, 0, N_("target for underlying storage")},
3969
4414
    {NULL, 0, 0, NULL}
3970
4415
};
3971
4416
 
4029
4474
 * "pool-create-as" command
4030
4475
 */
4031
4476
static const vshCmdInfo info_pool_create_as[] = {
4032
 
    {"help", gettext_noop("create a pool from a set of args")},
4033
 
    {"desc", gettext_noop("Create a pool.")},
 
4477
    {"help", N_("create a pool from a set of args")},
 
4478
    {"desc", N_("Create a pool.")},
4034
4479
    {NULL, NULL}
4035
4480
};
4036
4481
 
4070
4515
 * "pool-define" command
4071
4516
 */
4072
4517
static const vshCmdInfo info_pool_define[] = {
4073
 
    {"help", gettext_noop("define (but don't start) a pool from an XML file")},
4074
 
    {"desc", gettext_noop("Define a pool.")},
 
4518
    {"help", N_("define (but don't start) a pool from an XML file")},
 
4519
    {"desc", N_("Define a pool.")},
4075
4520
    {NULL, NULL}
4076
4521
};
4077
4522
 
4078
4523
static const vshCmdOptDef opts_pool_define[] = {
4079
 
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("file containing an XML pool description")},
 
4524
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML pool description")},
4080
4525
    {NULL, 0, 0, NULL}
4081
4526
};
4082
4527
 
4118
4563
 * "pool-define-as" command
4119
4564
 */
4120
4565
static const vshCmdInfo info_pool_define_as[] = {
4121
 
    {"help", gettext_noop("define a pool from a set of args")},
4122
 
    {"desc", gettext_noop("Define a pool.")},
 
4566
    {"help", N_("define a pool from a set of args")},
 
4567
    {"desc", N_("Define a pool.")},
4123
4568
    {NULL, NULL}
4124
4569
};
4125
4570
 
4159
4604
 * "pool-build" command
4160
4605
 */
4161
4606
static const vshCmdInfo info_pool_build[] = {
4162
 
    {"help", gettext_noop("build a pool")},
4163
 
    {"desc", gettext_noop("Build a given pool.")},
 
4607
    {"help", N_("build a pool")},
 
4608
    {"desc", N_("Build a given pool.")},
4164
4609
    {NULL, NULL}
4165
4610
};
4166
4611
 
4167
4612
static const vshCmdOptDef opts_pool_build[] = {
4168
 
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("pool name or uuid")},
 
4613
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name or uuid")},
4169
4614
    {NULL, 0, 0, NULL}
4170
4615
};
4171
4616
 
4199
4644
 * "pool-destroy" command
4200
4645
 */
4201
4646
static const vshCmdInfo info_pool_destroy[] = {
4202
 
    {"help", gettext_noop("destroy a pool")},
4203
 
    {"desc", gettext_noop("Destroy a given pool.")},
 
4647
    {"help", N_("destroy a pool")},
 
4648
    {"desc", N_("Destroy a given pool.")},
4204
4649
    {NULL, NULL}
4205
4650
};
4206
4651
 
4207
4652
static const vshCmdOptDef opts_pool_destroy[] = {
4208
 
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("pool name or uuid")},
 
4653
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name or uuid")},
4209
4654
    {NULL, 0, 0, NULL}
4210
4655
};
4211
4656
 
4238
4683
 * "pool-delete" command
4239
4684
 */
4240
4685
static const vshCmdInfo info_pool_delete[] = {
4241
 
    {"help", gettext_noop("delete a pool")},
4242
 
    {"desc", gettext_noop("Delete a given pool.")},
 
4686
    {"help", N_("delete a pool")},
 
4687
    {"desc", N_("Delete a given pool.")},
4243
4688
    {NULL, NULL}
4244
4689
};
4245
4690
 
4246
4691
static const vshCmdOptDef opts_pool_delete[] = {
4247
 
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("pool name or uuid")},
 
4692
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name or uuid")},
4248
4693
    {NULL, 0, 0, NULL}
4249
4694
};
4250
4695
 
4277
4722
 * "pool-refresh" command
4278
4723
 */
4279
4724
static const vshCmdInfo info_pool_refresh[] = {
4280
 
    {"help", gettext_noop("refresh a pool")},
4281
 
    {"desc", gettext_noop("Refresh a given pool.")},
 
4725
    {"help", N_("refresh a pool")},
 
4726
    {"desc", N_("Refresh a given pool.")},
4282
4727
    {NULL, NULL}
4283
4728
};
4284
4729
 
4285
4730
static const vshCmdOptDef opts_pool_refresh[] = {
4286
 
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("pool name or uuid")},
 
4731
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name or uuid")},
4287
4732
    {NULL, 0, 0, NULL}
4288
4733
};
4289
4734
 
4316
4761
 * "pool-dumpxml" command
4317
4762
 */
4318
4763
static const vshCmdInfo info_pool_dumpxml[] = {
4319
 
    {"help", gettext_noop("pool information in XML")},
4320
 
    {"desc", gettext_noop("Output the pool information as an XML dump to stdout.")},
 
4764
    {"help", N_("pool information in XML")},
 
4765
    {"desc", N_("Output the pool information as an XML dump to stdout.")},
4321
4766
    {NULL, NULL}
4322
4767
};
4323
4768
 
4324
4769
static const vshCmdOptDef opts_pool_dumpxml[] = {
4325
 
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("pool name or uuid")},
 
4770
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name or uuid")},
4326
4771
    {NULL, 0, 0, NULL}
4327
4772
};
4328
4773
 
4356
4801
 * "pool-list" command
4357
4802
 */
4358
4803
static const vshCmdInfo info_pool_list[] = {
4359
 
    {"help", gettext_noop("list pools")},
4360
 
    {"desc", gettext_noop("Returns list of pools.")},
 
4804
    {"help", N_("list pools")},
 
4805
    {"desc", N_("Returns list of pools.")},
4361
4806
    {NULL, NULL}
4362
4807
};
4363
4808
 
4364
4809
static const vshCmdOptDef opts_pool_list[] = {
4365
 
    {"inactive", VSH_OT_BOOL, 0, gettext_noop("list inactive pools")},
4366
 
    {"all", VSH_OT_BOOL, 0, gettext_noop("list inactive & active pools")},
 
4810
    {"inactive", VSH_OT_BOOL, 0, N_("list inactive pools")},
 
4811
    {"all", VSH_OT_BOOL, 0, N_("list inactive & active pools")},
4367
4812
    {NULL, 0, 0, NULL}
4368
4813
};
4369
4814
 
4478
4923
 * "find-storage-pool-sources-as" command
4479
4924
 */
4480
4925
static const vshCmdInfo info_find_storage_pool_sources_as[] = {
4481
 
    {"help", gettext_noop("find potential storage pool sources")},
4482
 
    {"desc", gettext_noop("Returns XML <sources> document.")},
 
4926
    {"help", N_("find potential storage pool sources")},
 
4927
    {"desc", N_("Returns XML <sources> document.")},
4483
4928
    {NULL, NULL}
4484
4929
};
4485
4930
 
4486
4931
static const vshCmdOptDef opts_find_storage_pool_sources_as[] = {
4487
4932
    {"type", VSH_OT_DATA, VSH_OFLAG_REQ,
4488
 
     gettext_noop("type of storage pool sources to find")},
4489
 
    {"host", VSH_OT_DATA, VSH_OFLAG_NONE, gettext_noop("optional host to query")},
4490
 
    {"port", VSH_OT_DATA, VSH_OFLAG_NONE, gettext_noop("optional port to query")},
 
4933
     N_("type of storage pool sources to find")},
 
4934
    {"host", VSH_OT_DATA, VSH_OFLAG_NONE, N_("optional host to query")},
 
4935
    {"port", VSH_OT_DATA, VSH_OFLAG_NONE, N_("optional port to query")},
4491
4936
    {NULL, 0, 0, NULL}
4492
4937
};
4493
4938
 
4558
5003
 * "find-storage-pool-sources" command
4559
5004
 */
4560
5005
static const vshCmdInfo info_find_storage_pool_sources[] = {
4561
 
    {"help", gettext_noop("discover potential storage pool sources")},
4562
 
    {"desc", gettext_noop("Returns XML <sources> document.")},
 
5006
    {"help", N_("discover potential storage pool sources")},
 
5007
    {"desc", N_("Returns XML <sources> document.")},
4563
5008
    {NULL, NULL}
4564
5009
};
4565
5010
 
4566
5011
static const vshCmdOptDef opts_find_storage_pool_sources[] = {
4567
5012
    {"type", VSH_OT_DATA, VSH_OFLAG_REQ,
4568
 
     gettext_noop("type of storage pool sources to discover")},
 
5013
     N_("type of storage pool sources to discover")},
4569
5014
    {"srcSpec", VSH_OT_DATA, VSH_OFLAG_NONE,
4570
 
     gettext_noop("optional file of source xml to query for pools")},
 
5015
     N_("optional file of source xml to query for pools")},
4571
5016
    {NULL, 0, 0, NULL}
4572
5017
};
4573
5018
 
4608
5053
 * "pool-info" command
4609
5054
 */
4610
5055
static const vshCmdInfo info_pool_info[] = {
4611
 
    {"help", gettext_noop("storage pool information")},
4612
 
    {"desc", gettext_noop("Returns basic information about the storage pool.")},
 
5056
    {"help", N_("storage pool information")},
 
5057
    {"desc", N_("Returns basic information about the storage pool.")},
4613
5058
    {NULL, NULL}
4614
5059
};
4615
5060
 
4616
5061
static const vshCmdOptDef opts_pool_info[] = {
4617
 
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("pool name or uuid")},
 
5062
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name or uuid")},
4618
5063
    {NULL, 0, 0, NULL}
4619
5064
};
4620
5065
 
4683
5128
 * "pool-name" command
4684
5129
 */
4685
5130
static const vshCmdInfo info_pool_name[] = {
4686
 
    {"help", gettext_noop("convert a pool UUID to pool name")},
 
5131
    {"help", N_("convert a pool UUID to pool name")},
4687
5132
    {"desc", ""},
4688
5133
    {NULL, NULL}
4689
5134
};
4690
5135
 
4691
5136
static const vshCmdOptDef opts_pool_name[] = {
4692
 
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("pool uuid")},
 
5137
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool uuid")},
4693
5138
    {NULL, 0, 0, NULL}
4694
5139
};
4695
5140
 
4714
5159
 * "pool-start" command
4715
5160
 */
4716
5161
static const vshCmdInfo info_pool_start[] = {
4717
 
    {"help", gettext_noop("start a (previously defined) inactive pool")},
4718
 
    {"desc", gettext_noop("Start a pool.")},
 
5162
    {"help", N_("start a (previously defined) inactive pool")},
 
5163
    {"desc", N_("Start a pool.")},
4719
5164
    {NULL, NULL}
4720
5165
};
4721
5166
 
4722
5167
static const vshCmdOptDef opts_pool_start[] = {
4723
 
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("name of the inactive pool")},
 
5168
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("name of the inactive pool")},
4724
5169
    {NULL, 0, 0, NULL}
4725
5170
};
4726
5171
 
4753
5198
 * "vol-create-as" command
4754
5199
 */
4755
5200
static const vshCmdInfo info_vol_create_as[] = {
4756
 
    {"help", gettext_noop("create a volume from a set of args")},
4757
 
    {"desc", gettext_noop("Create a vol.")},
 
5201
    {"help", N_("create a volume from a set of args")},
 
5202
    {"desc", N_("Create a vol.")},
4758
5203
    {NULL, NULL}
4759
5204
};
4760
5205
 
4761
5206
static const vshCmdOptDef opts_vol_create_as[] = {
4762
 
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("pool name")},
4763
 
    {"name", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("name of the volume")},
4764
 
    {"capacity", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("size of the vol with optional k,M,G,T suffix")},
4765
 
    {"allocation", VSH_OT_STRING, 0, gettext_noop("initial allocation size with optional k,M,G,T suffix")},
4766
 
    {"format", VSH_OT_STRING, 0, gettext_noop("file format type raw,bochs,qcow,qcow2,vmdk")},
 
5207
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name")},
 
5208
    {"name", VSH_OT_DATA, VSH_OFLAG_REQ, N_("name of the volume")},
 
5209
    {"capacity", VSH_OT_DATA, VSH_OFLAG_REQ, N_("size of the vol with optional k,M,G,T suffix")},
 
5210
    {"allocation", VSH_OT_STRING, 0, N_("initial allocation size with optional k,M,G,T suffix")},
 
5211
    {"format", VSH_OT_STRING, 0, N_("file format type raw,bochs,qcow,qcow2,vmdk")},
4767
5212
    {NULL, 0, 0, NULL}
4768
5213
};
4769
5214
 
4873
5318
 * "pool-undefine" command
4874
5319
 */
4875
5320
static const vshCmdInfo info_pool_undefine[] = {
4876
 
    {"help", gettext_noop("undefine an inactive pool")},
4877
 
    {"desc", gettext_noop("Undefine the configuration for an inactive pool.")},
 
5321
    {"help", N_("undefine an inactive pool")},
 
5322
    {"desc", N_("Undefine the configuration for an inactive pool.")},
4878
5323
    {NULL, NULL}
4879
5324
};
4880
5325
 
4881
5326
static const vshCmdOptDef opts_pool_undefine[] = {
4882
 
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("pool name or uuid")},
 
5327
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name or uuid")},
4883
5328
    {NULL, 0, 0, NULL}
4884
5329
};
4885
5330
 
4912
5357
 * "pool-uuid" command
4913
5358
 */
4914
5359
static const vshCmdInfo info_pool_uuid[] = {
4915
 
    {"help", gettext_noop("convert a pool name to pool UUID")},
 
5360
    {"help", N_("convert a pool name to pool UUID")},
4916
5361
    {"desc", ""},
4917
5362
    {NULL, NULL}
4918
5363
};
4919
5364
 
4920
5365
static const vshCmdOptDef opts_pool_uuid[] = {
4921
 
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("pool name")},
 
5366
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name")},
4922
5367
    {NULL, 0, 0, NULL}
4923
5368
};
4924
5369
 
4949
5394
 * "vol-create" command
4950
5395
 */
4951
5396
static const vshCmdInfo info_vol_create[] = {
4952
 
    {"help", gettext_noop("create a vol from an XML file")},
4953
 
    {"desc", gettext_noop("Create a vol.")},
 
5397
    {"help", N_("create a vol from an XML file")},
 
5398
    {"desc", N_("Create a vol.")},
4954
5399
    {NULL, NULL}
4955
5400
};
4956
5401
 
4957
5402
static const vshCmdOptDef opts_vol_create[] = {
4958
 
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("pool name")},
4959
 
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("file containing an XML vol description")},
 
5403
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name")},
 
5404
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML vol description")},
4960
5405
    {NULL, 0, 0, NULL}
4961
5406
};
4962
5407
 
4984
5429
    }
4985
5430
 
4986
5431
    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
 
5432
        virshReportError(ctl);
4987
5433
        virStoragePoolFree(pool);
4988
5434
        return FALSE;
4989
5435
    }
5007
5453
 * "vol-create-from" command
5008
5454
 */
5009
5455
static const vshCmdInfo info_vol_create_from[] = {
5010
 
    {"help", gettext_noop("create a vol, using another volume as input")},
5011
 
    {"desc", gettext_noop("Create a vol from an existing volume.")},
 
5456
    {"help", N_("create a vol, using another volume as input")},
 
5457
    {"desc", N_("Create a vol from an existing volume.")},
5012
5458
    {NULL, NULL}
5013
5459
};
5014
5460
 
5015
5461
static const vshCmdOptDef opts_vol_create_from[] = {
5016
 
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("pool name")},
5017
 
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("file containing an XML vol description")},
5018
 
    {"inputpool", VSH_OT_STRING, 0, gettext_noop("pool name or uuid of the input volume's pool")},
5019
 
    {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("input vol name or key")},
 
5462
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name")},
 
5463
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML vol description")},
 
5464
    {"inputpool", VSH_OT_STRING, 0, N_("pool name or uuid of the input volume's pool")},
 
5465
    {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("input vol name or key")},
5020
5466
    {NULL, 0, 0, NULL}
5021
5467
};
5022
5468
 
5045
5491
        goto cleanup;
5046
5492
 
5047
5493
    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
 
5494
        virshReportError(ctl);
5048
5495
        goto cleanup;
5049
5496
    }
5050
5497
 
5106
5553
 * "vol-clone" command
5107
5554
 */
5108
5555
static const vshCmdInfo info_vol_clone[] = {
5109
 
    {"help", gettext_noop("clone a volume.")},
5110
 
    {"desc", gettext_noop("Clone an existing volume.")},
 
5556
    {"help", N_("clone a volume.")},
 
5557
    {"desc", N_("Clone an existing volume.")},
5111
5558
    {NULL, NULL}
5112
5559
};
5113
5560
 
5114
5561
static const vshCmdOptDef opts_vol_clone[] = {
5115
 
    {"pool", VSH_OT_STRING, 0, gettext_noop("pool name or uuid")},
5116
 
    {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("orig vol name or key")},
5117
 
    {"newname", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("clone name")},
 
5562
    {"pool", VSH_OT_STRING, 0, N_("pool name or uuid")},
 
5563
    {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("orig vol name or key")},
 
5564
    {"newname", VSH_OT_DATA, VSH_OFLAG_REQ, N_("clone name")},
5118
5565
    {NULL, 0, 0, NULL}
5119
5566
};
5120
5567
 
5183
5630
 * "vol-delete" command
5184
5631
 */
5185
5632
static const vshCmdInfo info_vol_delete[] = {
5186
 
    {"help", gettext_noop("delete a vol")},
5187
 
    {"desc", gettext_noop("Delete a given vol.")},
 
5633
    {"help", N_("delete a vol")},
 
5634
    {"desc", N_("Delete a given vol.")},
5188
5635
    {NULL, NULL}
5189
5636
};
5190
5637
 
5191
5638
static const vshCmdOptDef opts_vol_delete[] = {
5192
 
    {"pool", VSH_OT_STRING, 0, gettext_noop("pool name or uuid")},
5193
 
    {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("vol name, key or path")},
 
5639
    {"pool", VSH_OT_STRING, 0, N_("pool name or uuid")},
 
5640
    {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("vol name, key or path")},
5194
5641
    {NULL, 0, 0, NULL}
5195
5642
};
5196
5643
 
5221
5668
 
5222
5669
 
5223
5670
/*
 
5671
 * "vol-wipe" command
 
5672
 */
 
5673
static const vshCmdInfo info_vol_wipe[] = {
 
5674
    {"help", N_("wipe a vol")},
 
5675
    {"desc", N_("Ensure data previously on a volume is not accessible to future reads")},
 
5676
    {NULL, NULL}
 
5677
};
 
5678
 
 
5679
static const vshCmdOptDef opts_vol_wipe[] = {
 
5680
    {"pool", VSH_OT_STRING, 0, N_("pool name or uuid")},
 
5681
    {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("vol name, key or path")},
 
5682
    {NULL, 0, 0, NULL}
 
5683
};
 
5684
 
 
5685
static int
 
5686
cmdVolWipe(vshControl *ctl, const vshCmd *cmd)
 
5687
{
 
5688
    virStorageVolPtr vol;
 
5689
    int ret = TRUE;
 
5690
    char *name;
 
5691
 
 
5692
    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
 
5693
        return FALSE;
 
5694
 
 
5695
    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {
 
5696
        return FALSE;
 
5697
    }
 
5698
 
 
5699
    if (virStorageVolWipe(vol, 0) == 0) {
 
5700
        vshPrint(ctl, _("Vol %s wiped\n"), name);
 
5701
    } else {
 
5702
        vshError(ctl, _("Failed to wipe vol %s"), name);
 
5703
        ret = FALSE;
 
5704
    }
 
5705
 
 
5706
    virStorageVolFree(vol);
 
5707
    return ret;
 
5708
}
 
5709
 
 
5710
 
 
5711
/*
5224
5712
 * "vol-info" command
5225
5713
 */
5226
5714
static const vshCmdInfo info_vol_info[] = {
5227
 
    {"help", gettext_noop("storage vol information")},
5228
 
    {"desc", gettext_noop("Returns basic information about the storage vol.")},
 
5715
    {"help", N_("storage vol information")},
 
5716
    {"desc", N_("Returns basic information about the storage vol.")},
5229
5717
    {NULL, NULL}
5230
5718
};
5231
5719
 
5232
5720
static const vshCmdOptDef opts_vol_info[] = {
5233
 
    {"pool", VSH_OT_STRING, 0, gettext_noop("pool name or uuid")},
5234
 
    {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("vol name, key or path")},
 
5721
    {"pool", VSH_OT_STRING, 0, N_("pool name or uuid")},
 
5722
    {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("vol name, key or path")},
5235
5723
    {NULL, 0, 0, NULL}
5236
5724
};
5237
5725
 
5275
5763
 * "vol-dumpxml" command
5276
5764
 */
5277
5765
static const vshCmdInfo info_vol_dumpxml[] = {
5278
 
    {"help", gettext_noop("vol information in XML")},
5279
 
    {"desc", gettext_noop("Output the vol information as an XML dump to stdout.")},
 
5766
    {"help", N_("vol information in XML")},
 
5767
    {"desc", N_("Output the vol information as an XML dump to stdout.")},
5280
5768
    {NULL, NULL}
5281
5769
};
5282
5770
 
5283
5771
static const vshCmdOptDef opts_vol_dumpxml[] = {
5284
 
    {"pool", VSH_OT_STRING, 0, gettext_noop("pool name or uuid")},
5285
 
    {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("vol name, key or path")},
 
5772
    {"pool", VSH_OT_STRING, 0, N_("pool name or uuid")},
 
5773
    {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("vol name, key or path")},
5286
5774
    {NULL, 0, 0, NULL}
5287
5775
};
5288
5776
 
5316
5804
 * "vol-list" command
5317
5805
 */
5318
5806
static const vshCmdInfo info_vol_list[] = {
5319
 
    {"help", gettext_noop("list vols")},
5320
 
    {"desc", gettext_noop("Returns list of vols by pool.")},
 
5807
    {"help", N_("list vols")},
 
5808
    {"desc", N_("Returns list of vols by pool.")},
5321
5809
    {NULL, NULL}
5322
5810
};
5323
5811
 
5324
5812
static const vshCmdOptDef opts_vol_list[] = {
5325
 
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("pool name or uuid")},
 
5813
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name or uuid")},
5326
5814
    {NULL, 0, 0, NULL}
5327
5815
};
5328
5816
 
5394
5882
 * "vol-name" command
5395
5883
 */
5396
5884
static const vshCmdInfo info_vol_name[] = {
5397
 
    {"help", gettext_noop("convert a vol UUID to vol name")},
 
5885
    {"help", N_("convert a vol UUID to vol name")},
5398
5886
    {"desc", ""},
5399
5887
    {NULL, NULL}
5400
5888
};
5401
5889
 
5402
5890
static const vshCmdOptDef opts_vol_name[] = {
5403
 
    {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("vol key or path")},
 
5891
    {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("vol key or path")},
5404
5892
    {NULL, 0, 0, NULL}
5405
5893
};
5406
5894
 
5427
5915
 * "vol-key" command
5428
5916
 */
5429
5917
static const vshCmdInfo info_vol_key[] = {
5430
 
    {"help", gettext_noop("convert a vol UUID to vol key")},
 
5918
    {"help", N_("convert a vol UUID to vol key")},
5431
5919
    {"desc", ""},
5432
5920
    {NULL, NULL}
5433
5921
};
5434
5922
 
5435
5923
static const vshCmdOptDef opts_vol_key[] = {
5436
 
    {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("vol uuid")},
 
5924
    {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("vol uuid")},
5437
5925
    {NULL, 0, 0, NULL}
5438
5926
};
5439
5927
 
5460
5948
 * "vol-path" command
5461
5949
 */
5462
5950
static const vshCmdInfo info_vol_path[] = {
5463
 
    {"help", gettext_noop("convert a vol UUID to vol path")},
 
5951
    {"help", N_("convert a vol UUID to vol path")},
5464
5952
    {"desc", ""},
5465
5953
    {NULL, NULL}
5466
5954
};
5467
5955
 
5468
5956
static const vshCmdOptDef opts_vol_path[] = {
5469
 
    {"pool", VSH_OT_STRING, 0, gettext_noop("pool name or uuid")},
5470
 
    {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("vol name or key")},
 
5957
    {"pool", VSH_OT_STRING, 0, N_("pool name or uuid")},
 
5958
    {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("vol name or key")},
5471
5959
    {NULL, 0, 0, NULL}
5472
5960
};
5473
5961
 
5494
5982
 * "secret-define" command
5495
5983
 */
5496
5984
static const vshCmdInfo info_secret_define[] = {
5497
 
    {"help", gettext_noop("define or modify a secret from an XML file")},
5498
 
    {"desc", gettext_noop("Define or modify a secret.")},
 
5985
    {"help", N_("define or modify a secret from an XML file")},
 
5986
    {"desc", N_("Define or modify a secret.")},
5499
5987
    {NULL, NULL}
5500
5988
};
5501
5989
 
5502
5990
static const vshCmdOptDef opts_secret_define[] = {
5503
 
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("file containing secret attributes in XML")},
 
5991
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing secret attributes in XML")},
5504
5992
    {NULL, 0, 0, NULL}
5505
5993
};
5506
5994
 
5542
6030
 * "secret-dumpxml" command
5543
6031
 */
5544
6032
static const vshCmdInfo info_secret_dumpxml[] = {
5545
 
    {"help", gettext_noop("secret attributes in XML")},
5546
 
    {"desc", gettext_noop("Output attributes of a secret as an XML dump to stdout.")},
 
6033
    {"help", N_("secret attributes in XML")},
 
6034
    {"desc", N_("Output attributes of a secret as an XML dump to stdout.")},
5547
6035
    {NULL, NULL}
5548
6036
};
5549
6037
 
5550
6038
static const vshCmdOptDef opts_secret_dumpxml[] = {
5551
 
    {"secret", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("secret UUID")},
 
6039
    {"secret", VSH_OT_DATA, VSH_OFLAG_REQ, N_("secret UUID")},
5552
6040
    {NULL, 0, 0, NULL}
5553
6041
};
5554
6042
 
5582
6070
 * "secret-set-value" command
5583
6071
 */
5584
6072
static const vshCmdInfo info_secret_set_value[] = {
5585
 
    {"help", gettext_noop("set a secret value")},
5586
 
    {"desc", gettext_noop("Set a secret value.")},
 
6073
    {"help", N_("set a secret value")},
 
6074
    {"desc", N_("Set a secret value.")},
5587
6075
    {NULL, NULL}
5588
6076
};
5589
6077
 
5590
6078
static const vshCmdOptDef opts_secret_set_value[] = {
5591
 
    {"secret", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("secret UUID")},
5592
 
    {"base64", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("base64-encoded secret value")},
 
6079
    {"secret", VSH_OT_DATA, VSH_OFLAG_REQ, N_("secret UUID")},
 
6080
    {"base64", VSH_OT_DATA, VSH_OFLAG_REQ, N_("base64-encoded secret value")},
5593
6081
    {NULL, 0, 0, NULL}
5594
6082
};
5595
6083
 
5641
6129
 * "secret-get-value" command
5642
6130
 */
5643
6131
static const vshCmdInfo info_secret_get_value[] = {
5644
 
    {"help", gettext_noop("Output a secret value")},
5645
 
    {"desc", gettext_noop("Output a secret value to stdout.")},
 
6132
    {"help", N_("Output a secret value")},
 
6133
    {"desc", N_("Output a secret value to stdout.")},
5646
6134
    {NULL, NULL}
5647
6135
};
5648
6136
 
5649
6137
static const vshCmdOptDef opts_secret_get_value[] = {
5650
 
    {"secret", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("secret UUID")},
 
6138
    {"secret", VSH_OT_DATA, VSH_OFLAG_REQ, N_("secret UUID")},
5651
6139
    {NULL, 0, 0, NULL}
5652
6140
};
5653
6141
 
5693
6181
 * "secret-undefine" command
5694
6182
 */
5695
6183
static const vshCmdInfo info_secret_undefine[] = {
5696
 
    {"help", gettext_noop("undefine a secret")},
5697
 
    {"desc", gettext_noop("Undefine a secret.")},
 
6184
    {"help", N_("undefine a secret")},
 
6185
    {"desc", N_("Undefine a secret.")},
5698
6186
    {NULL, NULL}
5699
6187
};
5700
6188
 
5701
6189
static const vshCmdOptDef opts_secret_undefine[] = {
5702
 
    {"secret", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("secret UUID")},
 
6190
    {"secret", VSH_OT_DATA, VSH_OFLAG_REQ, N_("secret UUID")},
5703
6191
    {NULL, 0, 0, NULL}
5704
6192
};
5705
6193
 
5733
6221
 * "secret-list" command
5734
6222
 */
5735
6223
static const vshCmdInfo info_secret_list[] = {
5736
 
    {"help", gettext_noop("list secrets")},
5737
 
    {"desc", gettext_noop("Returns a list of secrets")},
 
6224
    {"help", N_("list secrets")},
 
6225
    {"desc", N_("Returns a list of secrets")},
5738
6226
    {NULL, NULL}
5739
6227
};
5740
6228
 
5801
6289
 * "version" command
5802
6290
 */
5803
6291
static const vshCmdInfo info_version[] = {
5804
 
    {"help", gettext_noop("show version")},
5805
 
    {"desc", gettext_noop("Display the system version information.")},
 
6292
    {"help", N_("show version")},
 
6293
    {"desc", N_("Display the system version information.")},
5806
6294
    {NULL, NULL}
5807
6295
};
5808
6296
 
5880
6368
 * "nodedev-list" command
5881
6369
 */
5882
6370
static const vshCmdInfo info_node_list_devices[] = {
5883
 
    {"help", gettext_noop("enumerate devices on this host")},
 
6371
    {"help", N_("enumerate devices on this host")},
5884
6372
    {"desc", ""},
5885
6373
    {NULL, NULL}
5886
6374
};
5887
6375
 
5888
6376
static const vshCmdOptDef opts_node_list_devices[] = {
5889
 
    {"tree", VSH_OT_BOOL, 0, gettext_noop("list devices in a tree")},
5890
 
    {"cap", VSH_OT_STRING, VSH_OFLAG_NONE, gettext_noop("capability name")},
 
6377
    {"tree", VSH_OT_BOOL, 0, N_("list devices in a tree")},
 
6378
    {"cap", VSH_OT_STRING, VSH_OFLAG_NONE, N_("capability name")},
5891
6379
    {NULL, 0, 0, NULL}
5892
6380
};
5893
6381
 
6048
6536
 * "nodedev-dumpxml" command
6049
6537
 */
6050
6538
static const vshCmdInfo info_node_device_dumpxml[] = {
6051
 
    {"help", gettext_noop("node device details in XML")},
6052
 
    {"desc", gettext_noop("Output the node device details as an XML dump to stdout.")},
 
6539
    {"help", N_("node device details in XML")},
 
6540
    {"desc", N_("Output the node device details as an XML dump to stdout.")},
6053
6541
    {NULL, NULL}
6054
6542
};
6055
6543
 
6056
6544
 
6057
6545
static const vshCmdOptDef opts_node_device_dumpxml[] = {
6058
 
    {"device", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("device key")},
 
6546
    {"device", VSH_OT_DATA, VSH_OFLAG_REQ, N_("device key")},
6059
6547
    {NULL, 0, 0, NULL}
6060
6548
};
6061
6549
 
6091
6579
 * "nodedev-dettach" command
6092
6580
 */
6093
6581
static const vshCmdInfo info_node_device_dettach[] = {
6094
 
    {"help", gettext_noop("dettach node device from its device driver")},
6095
 
    {"desc", gettext_noop("Dettach node device from its device driver before assigning to a domain.")},
 
6582
    {"help", N_("dettach node device from its device driver")},
 
6583
    {"desc", N_("Dettach node device from its device driver before assigning to a domain.")},
6096
6584
    {NULL, NULL}
6097
6585
};
6098
6586
 
6099
6587
 
6100
6588
static const vshCmdOptDef opts_node_device_dettach[] = {
6101
 
    {"device", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("device key")},
 
6589
    {"device", VSH_OT_DATA, VSH_OFLAG_REQ, N_("device key")},
6102
6590
    {NULL, 0, 0, NULL}
6103
6591
};
6104
6592
 
6132
6620
 * "nodedev-reattach" command
6133
6621
 */
6134
6622
static const vshCmdInfo info_node_device_reattach[] = {
6135
 
    {"help", gettext_noop("reattach node device to its device driver")},
6136
 
    {"desc", gettext_noop("Reattach node device to its device driver once released by the domain.")},
 
6623
    {"help", N_("reattach node device to its device driver")},
 
6624
    {"desc", N_("Reattach node device to its device driver once released by the domain.")},
6137
6625
    {NULL, NULL}
6138
6626
};
6139
6627
 
6140
6628
 
6141
6629
static const vshCmdOptDef opts_node_device_reattach[] = {
6142
 
    {"device", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("device key")},
 
6630
    {"device", VSH_OT_DATA, VSH_OFLAG_REQ, N_("device key")},
6143
6631
    {NULL, 0, 0, NULL}
6144
6632
};
6145
6633
 
6173
6661
 * "nodedev-reset" command
6174
6662
 */
6175
6663
static const vshCmdInfo info_node_device_reset[] = {
6176
 
    {"help", gettext_noop("reset node device")},
6177
 
    {"desc", gettext_noop("Reset node device before or after assigning to a domain.")},
 
6664
    {"help", N_("reset node device")},
 
6665
    {"desc", N_("Reset node device before or after assigning to a domain.")},
6178
6666
    {NULL, NULL}
6179
6667
};
6180
6668
 
6181
6669
 
6182
6670
static const vshCmdOptDef opts_node_device_reset[] = {
6183
 
    {"device", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("device key")},
 
6671
    {"device", VSH_OT_DATA, VSH_OFLAG_REQ, N_("device key")},
6184
6672
    {NULL, 0, 0, NULL}
6185
6673
};
6186
6674
 
6214
6702
 * "hostkey" command
6215
6703
 */
6216
6704
static const vshCmdInfo info_hostname[] = {
6217
 
    {"help", gettext_noop("print the hypervisor hostname")},
 
6705
    {"help", N_("print the hypervisor hostname")},
6218
6706
    {"desc", ""},
6219
6707
    {NULL, NULL}
6220
6708
};
6243
6731
 * "uri" command
6244
6732
 */
6245
6733
static const vshCmdInfo info_uri[] = {
6246
 
    {"help", gettext_noop("print the hypervisor canonical URI")},
 
6734
    {"help", N_("print the hypervisor canonical URI")},
6247
6735
    {"desc", ""},
6248
6736
    {NULL, NULL}
6249
6737
};
6272
6760
 * "vncdisplay" command
6273
6761
 */
6274
6762
static const vshCmdInfo info_vncdisplay[] = {
6275
 
    {"help", gettext_noop("vnc display")},
6276
 
    {"desc", gettext_noop("Output the IP address and port number for the VNC display.")},
 
6763
    {"help", N_("vnc display")},
 
6764
    {"desc", N_("Output the IP address and port number for the VNC display.")},
6277
6765
    {NULL, NULL}
6278
6766
};
6279
6767
 
6280
6768
static const vshCmdOptDef opts_vncdisplay[] = {
6281
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
 
6769
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
6282
6770
    {NULL, 0, 0, NULL}
6283
6771
};
6284
6772
 
6347
6835
 * "ttyconsole" command
6348
6836
 */
6349
6837
static const vshCmdInfo info_ttyconsole[] = {
6350
 
    {"help", gettext_noop("tty console")},
6351
 
    {"desc", gettext_noop("Output the device for the TTY console.")},
 
6838
    {"help", N_("tty console")},
 
6839
    {"desc", N_("Output the device for the TTY console.")},
6352
6840
    {NULL, NULL}
6353
6841
};
6354
6842
 
6355
6843
static const vshCmdOptDef opts_ttyconsole[] = {
6356
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
 
6844
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
6357
6845
    {NULL, 0, 0, NULL}
6358
6846
};
6359
6847
 
6408
6896
 * "attach-device" command
6409
6897
 */
6410
6898
static const vshCmdInfo info_attach_device[] = {
6411
 
    {"help", gettext_noop("attach device from an XML file")},
6412
 
    {"desc", gettext_noop("Attach device from an XML <file>.")},
 
6899
    {"help", N_("attach device from an XML file")},
 
6900
    {"desc", N_("Attach device from an XML <file>.")},
6413
6901
    {NULL, NULL}
6414
6902
};
6415
6903
 
6416
6904
static const vshCmdOptDef opts_attach_device[] = {
6417
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
6418
 
    {"file",   VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("XML file")},
6419
 
    {"persistent", VSH_OT_BOOL, 0, gettext_noop("persist device attachment")},
 
6905
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
6906
    {"file",   VSH_OT_DATA, VSH_OFLAG_REQ, N_("XML file")},
 
6907
    {"persistent", VSH_OT_BOOL, 0, N_("persist device attachment")},
6420
6908
    {NULL, 0, 0, NULL}
6421
6909
};
6422
6910
 
6444
6932
    }
6445
6933
 
6446
6934
    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
 
6935
        virshReportError(ctl);
6447
6936
        virDomainFree(dom);
6448
6937
        return FALSE;
6449
6938
    }
6475
6964
 * "detach-device" command
6476
6965
 */
6477
6966
static const vshCmdInfo info_detach_device[] = {
6478
 
    {"help", gettext_noop("detach device from an XML file")},
6479
 
    {"desc", gettext_noop("Detach device from an XML <file>")},
 
6967
    {"help", N_("detach device from an XML file")},
 
6968
    {"desc", N_("Detach device from an XML <file>")},
6480
6969
    {NULL, NULL}
6481
6970
};
6482
6971
 
6483
6972
static const vshCmdOptDef opts_detach_device[] = {
6484
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
6485
 
    {"file",   VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("XML file")},
6486
 
    {"persistent", VSH_OT_BOOL, 0, gettext_noop("persist device detachment")},
 
6973
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
6974
    {"file",   VSH_OT_DATA, VSH_OFLAG_REQ, N_("XML file")},
 
6975
    {"persistent", VSH_OT_BOOL, 0, N_("persist device detachment")},
6487
6976
    {NULL, 0, 0, NULL}
6488
6977
};
6489
6978
 
6511
7000
    }
6512
7001
 
6513
7002
    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
 
7003
        virshReportError(ctl);
6514
7004
        virDomainFree(dom);
6515
7005
        return FALSE;
6516
7006
    }
6539
7029
 
6540
7030
 
6541
7031
/*
 
7032
 * "update-device" command
 
7033
 */
 
7034
static const vshCmdInfo info_update_device[] = {
 
7035
    {"help", N_("update device from an XML file")},
 
7036
    {"desc", N_("Update device from an XML <file>.")},
 
7037
    {NULL, NULL}
 
7038
};
 
7039
 
 
7040
static const vshCmdOptDef opts_update_device[] = {
 
7041
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
7042
    {"file",   VSH_OT_DATA, VSH_OFLAG_REQ, N_("XML file")},
 
7043
    {"persistent", VSH_OT_BOOL, 0, N_("persist device update")},
 
7044
    {NULL, 0, 0, NULL}
 
7045
};
 
7046
 
 
7047
static int
 
7048
cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd)
 
7049
{
 
7050
    virDomainPtr dom;
 
7051
    char *from;
 
7052
    char *buffer;
 
7053
    int ret = TRUE;
 
7054
    int found;
 
7055
    unsigned int flags;
 
7056
 
 
7057
    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
 
7058
        return FALSE;
 
7059
 
 
7060
    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
 
7061
        return FALSE;
 
7062
 
 
7063
    from = vshCommandOptString(cmd, "file", &found);
 
7064
    if (!found) {
 
7065
        vshError(ctl, "%s", _("update-device: Missing <file> option"));
 
7066
        virDomainFree(dom);
 
7067
        return FALSE;
 
7068
    }
 
7069
 
 
7070
    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
 
7071
        virshReportError(ctl);
 
7072
        virDomainFree(dom);
 
7073
        return FALSE;
 
7074
    }
 
7075
 
 
7076
    if (vshCommandOptBool(cmd, "persistent")) {
 
7077
        flags = VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
 
7078
        if (virDomainIsActive(dom) == 1)
 
7079
           flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
 
7080
    } else {
 
7081
        flags = VIR_DOMAIN_DEVICE_MODIFY_LIVE;
 
7082
    }
 
7083
    ret = virDomainUpdateDeviceFlags(dom, buffer, flags);
 
7084
    VIR_FREE(buffer);
 
7085
 
 
7086
    if (ret < 0) {
 
7087
        vshError(ctl, _("Failed to update device from %s"), from);
 
7088
        virDomainFree(dom);
 
7089
        return FALSE;
 
7090
    } else {
 
7091
        vshPrint(ctl, "%s", _("Device updated successfully\n"));
 
7092
    }
 
7093
 
 
7094
    virDomainFree(dom);
 
7095
    return TRUE;
 
7096
}
 
7097
 
 
7098
 
 
7099
/*
6542
7100
 * "attach-interface" command
6543
7101
 */
6544
7102
static const vshCmdInfo info_attach_interface[] = {
6545
 
    {"help", gettext_noop("attach network interface")},
6546
 
    {"desc", gettext_noop("Attach new network interface.")},
 
7103
    {"help", N_("attach network interface")},
 
7104
    {"desc", N_("Attach new network interface.")},
6547
7105
    {NULL, NULL}
6548
7106
};
6549
7107
 
6550
7108
static const vshCmdOptDef opts_attach_interface[] = {
6551
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
6552
 
    {"type",   VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("network interface type")},
6553
 
    {"source", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("source of network interface")},
6554
 
    {"target", VSH_OT_DATA, 0, gettext_noop("target network name")},
6555
 
    {"mac",    VSH_OT_DATA, 0, gettext_noop("MAC address")},
6556
 
    {"script", VSH_OT_DATA, 0, gettext_noop("script used to bridge network interface")},
6557
 
    {"persistent", VSH_OT_BOOL, 0, gettext_noop("persist interface attachment")},
 
7109
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
7110
    {"type",   VSH_OT_DATA, VSH_OFLAG_REQ, N_("network interface type")},
 
7111
    {"source", VSH_OT_DATA, VSH_OFLAG_REQ, N_("source of network interface")},
 
7112
    {"target", VSH_OT_DATA, 0, N_("target network name")},
 
7113
    {"mac",    VSH_OT_DATA, 0, N_("MAC address")},
 
7114
    {"script", VSH_OT_DATA, 0, N_("script used to bridge network interface")},
 
7115
    {"persistent", VSH_OT_BOOL, 0, N_("persist interface attachment")},
6558
7116
    {NULL, 0, 0, NULL}
6559
7117
};
6560
7118
 
6650
7208
    }
6651
7209
 
6652
7210
    if (ret != 0) {
6653
 
        vshError(ctl, _("Failed to attach interface"));
 
7211
        vshError(ctl, "%s", _("Failed to attach interface"));
6654
7212
        ret = FALSE;
6655
7213
    } else {
6656
7214
        vshPrint(ctl, "%s", _("Interface attached successfully\n"));
6669
7227
 * "detach-interface" command
6670
7228
 */
6671
7229
static const vshCmdInfo info_detach_interface[] = {
6672
 
    {"help", gettext_noop("detach network interface")},
6673
 
    {"desc", gettext_noop("Detach network interface.")},
 
7230
    {"help", N_("detach network interface")},
 
7231
    {"desc", N_("Detach network interface.")},
6674
7232
    {NULL, NULL}
6675
7233
};
6676
7234
 
6677
7235
static const vshCmdOptDef opts_detach_interface[] = {
6678
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
6679
 
    {"type",   VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("network interface type")},
6680
 
    {"mac",    VSH_OT_STRING, 0, gettext_noop("MAC address")},
6681
 
    {"persistent", VSH_OT_BOOL, 0, gettext_noop("persist interface detachment")},
 
7236
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
7237
    {"type",   VSH_OT_DATA, VSH_OFLAG_REQ, N_("network interface type")},
 
7238
    {"mac",    VSH_OT_STRING, 0, N_("MAC address")},
 
7239
    {"persistent", VSH_OT_BOOL, 0, N_("persist interface detachment")},
6682
7240
    {NULL, 0, 0, NULL}
6683
7241
};
6684
7242
 
6779
7337
    }
6780
7338
 
6781
7339
    if (ret != 0) {
6782
 
        vshError(ctl, _("Failed to detach interface"));
 
7340
        vshError(ctl, "%s", _("Failed to detach interface"));
6783
7341
        ret = FALSE;
6784
7342
    } else {
6785
7343
        vshPrint(ctl, "%s", _("Interface detached successfully\n"));
6802
7360
 * "attach-disk" command
6803
7361
 */
6804
7362
static const vshCmdInfo info_attach_disk[] = {
6805
 
    {"help", gettext_noop("attach disk device")},
6806
 
    {"desc", gettext_noop("Attach new disk device.")},
 
7363
    {"help", N_("attach disk device")},
 
7364
    {"desc", N_("Attach new disk device.")},
6807
7365
    {NULL, NULL}
6808
7366
};
6809
7367
 
6810
7368
static const vshCmdOptDef opts_attach_disk[] = {
6811
 
    {"domain",  VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
6812
 
    {"source",  VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("source of disk device")},
6813
 
    {"target",  VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("target of disk device")},
6814
 
    {"driver",    VSH_OT_STRING, 0, gettext_noop("driver of disk device")},
6815
 
    {"subdriver", VSH_OT_STRING, 0, gettext_noop("subdriver of disk device")},
6816
 
    {"type",    VSH_OT_STRING, 0, gettext_noop("target device type")},
6817
 
    {"mode",    VSH_OT_STRING, 0, gettext_noop("mode of device reading and writing")},
6818
 
    {"persistent", VSH_OT_BOOL, 0, gettext_noop("persist disk attachment")},
 
7369
    {"domain",  VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
7370
    {"source",  VSH_OT_DATA, VSH_OFLAG_REQ, N_("source of disk device")},
 
7371
    {"target",  VSH_OT_DATA, VSH_OFLAG_REQ, N_("target of disk device")},
 
7372
    {"driver",    VSH_OT_STRING, 0, N_("driver of disk device")},
 
7373
    {"subdriver", VSH_OT_STRING, 0, N_("subdriver of disk device")},
 
7374
    {"type",    VSH_OT_STRING, 0, N_("target device type")},
 
7375
    {"mode",    VSH_OT_STRING, 0, N_("mode of device reading and writing")},
 
7376
    {"persistent", VSH_OT_BOOL, 0, N_("persist disk attachment")},
6819
7377
    {NULL, 0, 0, NULL}
6820
7378
};
6821
7379
 
6952
7510
    }
6953
7511
 
6954
7512
    if (ret != 0) {
6955
 
        vshError(ctl, _("Failed to attach disk"));
 
7513
        vshError(ctl, "%s", _("Failed to attach disk"));
6956
7514
        ret = FALSE;
6957
7515
    } else {
6958
7516
        vshPrint(ctl, "%s", _("Disk attached successfully\n"));
6971
7529
 * "detach-disk" command
6972
7530
 */
6973
7531
static const vshCmdInfo info_detach_disk[] = {
6974
 
    {"help", gettext_noop("detach disk device")},
6975
 
    {"desc", gettext_noop("Detach disk device.")},
 
7532
    {"help", N_("detach disk device")},
 
7533
    {"desc", N_("Detach disk device.")},
6976
7534
    {NULL, NULL}
6977
7535
};
6978
7536
 
6979
7537
static const vshCmdOptDef opts_detach_disk[] = {
6980
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
6981
 
    {"target", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("target of disk device")},
6982
 
    {"persistent", VSH_OT_BOOL, 0, gettext_noop("persist disk detachment")},
 
7538
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
7539
    {"target", VSH_OT_DATA, VSH_OFLAG_REQ, N_("target of disk device")},
 
7540
    {"persistent", VSH_OT_BOOL, 0, N_("persist disk detachment")},
6983
7541
    {NULL, 0, 0, NULL}
6984
7542
};
6985
7543
 
7073
7631
    }
7074
7632
 
7075
7633
    if (ret != 0) {
7076
 
        vshError(ctl, _("Failed to detach disk"));
 
7634
        vshError(ctl, "%s", _("Failed to detach disk"));
7077
7635
        ret = FALSE;
7078
7636
    } else {
7079
7637
        vshPrint(ctl, "%s", _("Disk detached successfully\n"));
7096
7654
 * "cpu-compare" command
7097
7655
 */
7098
7656
static const vshCmdInfo info_cpu_compare[] = {
7099
 
    {"help", gettext_noop("compare host CPU with a CPU described by an XML file")},
7100
 
    {"desc", gettext_noop("compare CPU with host CPU")},
 
7657
    {"help", N_("compare host CPU with a CPU described by an XML file")},
 
7658
    {"desc", N_("compare CPU with host CPU")},
7101
7659
    {NULL, NULL}
7102
7660
};
7103
7661
 
7104
7662
static const vshCmdOptDef opts_cpu_compare[] = {
7105
 
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("file containing an XML CPU description")},
 
7663
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML CPU description")},
7106
7664
    {NULL, 0, 0, NULL}
7107
7665
};
7108
7666
 
7160
7718
 * "cpu-baseline" command
7161
7719
 */
7162
7720
static const vshCmdInfo info_cpu_baseline[] = {
7163
 
    {"help", gettext_noop("compute baseline CPU")},
7164
 
    {"desc", gettext_noop("Compute baseline CPU for a set of given CPUs.")},
 
7721
    {"help", N_("compute baseline CPU")},
 
7722
    {"desc", N_("Compute baseline CPU for a set of given CPUs.")},
7165
7723
    {NULL, NULL}
7166
7724
};
7167
7725
 
7168
7726
static const vshCmdOptDef opts_cpu_baseline[] = {
7169
 
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("file containing XML CPU descriptions")},
 
7727
    {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing XML CPU descriptions")},
7170
7728
    {NULL, 0, 0, NULL}
7171
7729
};
7172
7730
 
7202
7760
    if (doc == NULL)
7203
7761
        goto no_memory;
7204
7762
 
7205
 
    res = xmlParseBalancedChunkMemory(doc, NULL, NULL, 0, buffer, &node_list);
 
7763
    res = xmlParseBalancedChunkMemory(doc, NULL, NULL, 0,
 
7764
                                      (const xmlChar *)buffer, &node_list);
7206
7765
    if (res != 0) {
7207
7766
        vshError(ctl, _("Failed to parse XML fragment %s"), from);
7208
7767
        ret = FALSE;
7330
7889
    char *command;
7331
7890
    int command_ret;
7332
7891
 
7333
 
    editor = getenv ("EDITOR");
 
7892
    editor = getenv ("VISUAL");
 
7893
    if (!editor) editor = getenv ("EDITOR");
7334
7894
    if (!editor) editor = "vi"; /* could be cruel & default to ed(1) here */
7335
7895
 
7336
 
    /* Check the editor doesn't contain shell meta-characters, and if
7337
 
     * it does, refuse to run.
 
7896
    /* Check that filename doesn't contain shell meta-characters, and
 
7897
     * if it does, refuse to run.  Follow the Unix conventions for
 
7898
     * EDITOR: the user can intentionally specify command options, so
 
7899
     * we don't protect any shell metacharacters there.  Lots more
 
7900
     * than virsh will misbehave if EDITOR has bogus contents (which
 
7901
     * is why sudo scrubs it by default).
7338
7902
     */
7339
 
    if (strspn (editor, ACCEPTED_CHARS) != strlen (editor)) {
7340
 
        vshError(ctl,
7341
 
                 _("%s: $EDITOR environment variable contains shell meta or "
7342
 
                   "other unacceptable characters"),
7343
 
                 editor);
7344
 
        return -1;
7345
 
    }
7346
 
    /* Same for the filename. */
7347
7903
    if (strspn (filename, ACCEPTED_CHARS) != strlen (filename)) {
7348
7904
        vshError(ctl,
7349
7905
                 _("%s: temporary filename contains shell meta or other "
7396
7952
 * "cd" command
7397
7953
 */
7398
7954
static const vshCmdInfo info_cd[] = {
7399
 
    {"help", gettext_noop("change the current directory")},
7400
 
    {"desc", gettext_noop("Change the current directory.")},
 
7955
    {"help", N_("change the current directory")},
 
7956
    {"desc", N_("Change the current directory.")},
7401
7957
    {NULL, NULL}
7402
7958
};
7403
7959
 
7404
7960
static const vshCmdOptDef opts_cd[] = {
7405
 
    {"dir", VSH_OT_DATA, 0, gettext_noop("directory to switch to (default: home or else root)")},
 
7961
    {"dir", VSH_OT_DATA, 0, N_("directory to switch to (default: home or else root)")},
7406
7962
    {NULL, 0, 0, NULL}
7407
7963
};
7408
7964
 
7414
7970
 
7415
7971
    if (!ctl->imode) {
7416
7972
        vshError(ctl, "%s", _("cd: command valid only in interactive mode"));
7417
 
        return -1;
 
7973
        return FALSE;
7418
7974
    }
7419
7975
 
7420
7976
    dir = vshCommandOptString(cmd, "dir", &found);
7427
7983
 
7428
7984
    if (chdir (dir) == -1) {
7429
7985
        vshError(ctl, _("cd: %s: %s"), strerror(errno), dir);
7430
 
        return -1;
 
7986
        return FALSE;
7431
7987
    }
7432
7988
 
7433
 
    return 0;
 
7989
    return TRUE;
7434
7990
}
7435
7991
 
7436
7992
#endif
7440
7996
 * "pwd" command
7441
7997
 */
7442
7998
static const vshCmdInfo info_pwd[] = {
7443
 
    {"help", gettext_noop("print the current directory")},
7444
 
    {"desc", gettext_noop("Print the current directory.")},
 
7999
    {"help", N_("print the current directory")},
 
8000
    {"desc", N_("Print the current directory.")},
7445
8001
    {NULL, NULL}
7446
8002
};
7447
8003
 
7478
8034
 * "edit" command
7479
8035
 */
7480
8036
static const vshCmdInfo info_edit[] = {
7481
 
    {"help", gettext_noop("edit XML configuration for a domain")},
7482
 
    {"desc", gettext_noop("Edit the XML configuration for a domain.")},
 
8037
    {"help", N_("edit XML configuration for a domain")},
 
8038
    {"desc", N_("Edit the XML configuration for a domain.")},
7483
8039
    {NULL, NULL}
7484
8040
};
7485
8041
 
7486
8042
static const vshCmdOptDef opts_edit[] = {
7487
 
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
 
8043
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
7488
8044
    {NULL, 0, 0, NULL}
7489
8045
};
7490
8046
 
7581
8137
 * "net-edit" command
7582
8138
 */
7583
8139
static const vshCmdInfo info_network_edit[] = {
7584
 
    {"help", gettext_noop("edit XML configuration for a network")},
7585
 
    {"desc", gettext_noop("Edit the XML configuration for a network.")},
 
8140
    {"help", N_("edit XML configuration for a network")},
 
8141
    {"desc", N_("Edit the XML configuration for a network.")},
7586
8142
    {NULL, NULL}
7587
8143
};
7588
8144
 
7589
8145
static const vshCmdOptDef opts_network_edit[] = {
7590
 
    {"network", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("network name, id or uuid")},
 
8146
    {"network", VSH_OT_DATA, VSH_OFLAG_REQ, N_("network name, id or uuid")},
7591
8147
    {NULL, 0, 0, NULL}
7592
8148
};
7593
8149
 
7598
8154
 * "pool-edit" command
7599
8155
 */
7600
8156
static const vshCmdInfo info_pool_edit[] = {
7601
 
    {"help", gettext_noop("edit XML configuration for a storage pool")},
7602
 
    {"desc", gettext_noop("Edit the XML configuration for a storage pool.")},
 
8157
    {"help", N_("edit XML configuration for a storage pool")},
 
8158
    {"desc", N_("Edit the XML configuration for a storage pool.")},
7603
8159
    {NULL, NULL}
7604
8160
};
7605
8161
 
7606
8162
static const vshCmdOptDef opts_pool_edit[] = {
7607
 
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("pool name or uuid")},
 
8163
    {"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name or uuid")},
7608
8164
    {NULL, 0, 0, NULL}
7609
8165
};
7610
8166
 
7615
8171
 * "quit" command
7616
8172
 */
7617
8173
static const vshCmdInfo info_quit[] = {
7618
 
    {"help", gettext_noop("quit this interactive terminal")},
 
8174
    {"help", N_("quit this interactive terminal")},
7619
8175
    {"desc", ""},
7620
8176
    {NULL, NULL}
7621
8177
};
7628
8184
}
7629
8185
 
7630
8186
/*
 
8187
 * "snapshot-create" command
 
8188
 */
 
8189
static const vshCmdInfo info_snapshot_create[] = {
 
8190
    {"help", N_("Create a snapshot")},
 
8191
    {"desc", N_("Snapshot create")},
 
8192
    {NULL, NULL}
 
8193
};
 
8194
 
 
8195
static const vshCmdOptDef opts_snapshot_create[] = {
 
8196
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
8197
    {"xmlfile", VSH_OT_DATA, 0, N_("domain snapshot XML")},
 
8198
    {NULL, 0, 0, NULL}
 
8199
};
 
8200
 
 
8201
static int
 
8202
cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
 
8203
{
 
8204
    virDomainPtr dom = NULL;
 
8205
    int ret = FALSE;
 
8206
    char *from;
 
8207
    char *buffer = NULL;
 
8208
    virDomainSnapshotPtr snapshot = NULL;
 
8209
    xmlDocPtr xml = NULL;
 
8210
    xmlXPathContextPtr ctxt = NULL;
 
8211
    char *doc = NULL;
 
8212
    char *name = NULL;
 
8213
 
 
8214
    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
 
8215
        goto cleanup;
 
8216
 
 
8217
    dom = vshCommandOptDomain(ctl, cmd, NULL);
 
8218
    if (dom == NULL)
 
8219
        goto cleanup;
 
8220
 
 
8221
    from = vshCommandOptString(cmd, "xmlfile", NULL);
 
8222
    if (from == NULL)
 
8223
        buffer = strdup("<domainsnapshot/>");
 
8224
    else {
 
8225
        if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
 
8226
            /* we have to report the error here because during cleanup
 
8227
             * we'll run through virDomainFree(), which loses the
 
8228
             * last error
 
8229
             */
 
8230
            virshReportError(ctl);
 
8231
            goto cleanup;
 
8232
        }
 
8233
    }
 
8234
    if (buffer == NULL) {
 
8235
        vshError(ctl, "%s", _("Out of memory"));
 
8236
        goto cleanup;
 
8237
    }
 
8238
 
 
8239
    snapshot = virDomainSnapshotCreateXML(dom, buffer, 0);
 
8240
    if (snapshot == NULL)
 
8241
        goto cleanup;
 
8242
 
 
8243
    doc = virDomainSnapshotGetXMLDesc(snapshot, 0);
 
8244
    if (!doc)
 
8245
        goto cleanup;
 
8246
 
 
8247
    xml = xmlReadDoc((const xmlChar *) doc, "domainsnapshot.xml", NULL,
 
8248
                     XML_PARSE_NOENT | XML_PARSE_NONET |
 
8249
                     XML_PARSE_NOWARNING);
 
8250
    if (!xml)
 
8251
        goto cleanup;
 
8252
    ctxt = xmlXPathNewContext(xml);
 
8253
    if (!ctxt)
 
8254
        goto cleanup;
 
8255
 
 
8256
    name = virXPathString("string(/domainsnapshot/name)", ctxt);
 
8257
    if (!name) {
 
8258
        vshError(ctl, "%s",
 
8259
                 _("Could not find 'name' element in domain snapshot XML"));
 
8260
        goto cleanup;
 
8261
    }
 
8262
 
 
8263
    vshPrint(ctl, _("Domain snapshot %s created"), name);
 
8264
    if (from)
 
8265
        vshPrint(ctl, _(" from '%s'"), from);
 
8266
    vshPrint(ctl, "\n");
 
8267
 
 
8268
    ret = TRUE;
 
8269
 
 
8270
cleanup:
 
8271
    VIR_FREE(name);
 
8272
    xmlXPathFreeContext(ctxt);
 
8273
    if (xml)
 
8274
        xmlFreeDoc(xml);
 
8275
    if (snapshot)
 
8276
        virDomainSnapshotFree(snapshot);
 
8277
    VIR_FREE(doc);
 
8278
    VIR_FREE(buffer);
 
8279
    if (dom)
 
8280
        virDomainFree(dom);
 
8281
 
 
8282
    return ret;
 
8283
}
 
8284
 
 
8285
/*
 
8286
 * "snapshot-current" command
 
8287
 */
 
8288
static const vshCmdInfo info_snapshot_current[] = {
 
8289
    {"help", N_("Get the current snapshot")},
 
8290
    {"desc", N_("Get the current snapshot")},
 
8291
    {NULL, NULL}
 
8292
};
 
8293
 
 
8294
static const vshCmdOptDef opts_snapshot_current[] = {
 
8295
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
8296
    {NULL, 0, 0, NULL}
 
8297
};
 
8298
 
 
8299
static int
 
8300
cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
 
8301
{
 
8302
    virDomainPtr dom = NULL;
 
8303
    int ret = FALSE;
 
8304
    int current;
 
8305
    virDomainSnapshotPtr snapshot = NULL;
 
8306
 
 
8307
    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
 
8308
        goto cleanup;
 
8309
 
 
8310
    dom = vshCommandOptDomain(ctl, cmd, NULL);
 
8311
    if (dom == NULL)
 
8312
        goto cleanup;
 
8313
 
 
8314
    current = virDomainHasCurrentSnapshot(dom, 0);
 
8315
    if (current < 0)
 
8316
        goto cleanup;
 
8317
    else if (current) {
 
8318
        char *xml;
 
8319
 
 
8320
        if (!(snapshot = virDomainSnapshotCurrent(dom, 0)))
 
8321
            goto cleanup;
 
8322
 
 
8323
        xml = virDomainSnapshotGetXMLDesc(snapshot, 0);
 
8324
        if (!xml)
 
8325
            goto cleanup;
 
8326
 
 
8327
        vshPrint(ctl, "%s", xml);
 
8328
        VIR_FREE(xml);
 
8329
    }
 
8330
 
 
8331
    ret = TRUE;
 
8332
 
 
8333
cleanup:
 
8334
    if (snapshot)
 
8335
        virDomainSnapshotFree(snapshot);
 
8336
    if (dom)
 
8337
        virDomainFree(dom);
 
8338
 
 
8339
    return ret;
 
8340
}
 
8341
 
 
8342
/*
 
8343
 * "snapshot-list" command
 
8344
 */
 
8345
static const vshCmdInfo info_snapshot_list[] = {
 
8346
    {"help", N_("List snapshots for a domain")},
 
8347
    {"desc", N_("Snapshot List")},
 
8348
    {NULL, NULL}
 
8349
};
 
8350
 
 
8351
static const vshCmdOptDef opts_snapshot_list[] = {
 
8352
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
8353
    {NULL, 0, 0, NULL}
 
8354
};
 
8355
 
 
8356
static int
 
8357
cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
 
8358
{
 
8359
    virDomainPtr dom = NULL;
 
8360
    int ret = FALSE;
 
8361
    int numsnaps;
 
8362
    char **names = NULL;
 
8363
    int actual;
 
8364
    int i;
 
8365
    xmlDocPtr xml = NULL;
 
8366
    xmlXPathContextPtr ctxt = NULL;
 
8367
    char *doc = NULL;
 
8368
    virDomainSnapshotPtr snapshot = NULL;
 
8369
    char *state = NULL;
 
8370
    long creation;
 
8371
    char timestr[100];
 
8372
    struct tm time_info;
 
8373
 
 
8374
    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
 
8375
        goto cleanup;
 
8376
 
 
8377
    dom = vshCommandOptDomain(ctl, cmd, NULL);
 
8378
    if (dom == NULL)
 
8379
        goto cleanup;
 
8380
 
 
8381
    numsnaps = virDomainSnapshotNum(dom, 0);
 
8382
 
 
8383
    if (numsnaps < 0)
 
8384
        goto cleanup;
 
8385
 
 
8386
    vshPrint(ctl, " %-20s %-25s %s\n", _("Name"), _("Creation Time"), _("State"));
 
8387
    vshPrint(ctl, "---------------------------------------------------\n");
 
8388
 
 
8389
    if (numsnaps) {
 
8390
        if (VIR_ALLOC_N(names, numsnaps) < 0)
 
8391
            goto cleanup;
 
8392
 
 
8393
        actual = virDomainSnapshotListNames(dom, names, numsnaps, 0);
 
8394
        if (actual < 0)
 
8395
            goto cleanup;
 
8396
 
 
8397
        qsort(&names[0], actual, sizeof(char*), namesorter);
 
8398
 
 
8399
        for (i = 0; i < actual; i++) {
 
8400
            /* free up memory from previous iterations of the loop */
 
8401
            VIR_FREE(state);
 
8402
            if (snapshot)
 
8403
                virDomainSnapshotFree(snapshot);
 
8404
            xmlXPathFreeContext(ctxt);
 
8405
            if (xml)
 
8406
                xmlFreeDoc(xml);
 
8407
            VIR_FREE(doc);
 
8408
 
 
8409
            snapshot = virDomainSnapshotLookupByName(dom, names[i], 0);
 
8410
            if (snapshot == NULL)
 
8411
                continue;
 
8412
 
 
8413
            doc = virDomainSnapshotGetXMLDesc(snapshot, 0);
 
8414
            if (!doc)
 
8415
                continue;
 
8416
 
 
8417
            xml = xmlReadDoc((const xmlChar *) doc, "domainsnapshot.xml", NULL,
 
8418
                             XML_PARSE_NOENT | XML_PARSE_NONET |
 
8419
                             XML_PARSE_NOWARNING);
 
8420
            if (!xml)
 
8421
                continue;
 
8422
            ctxt = xmlXPathNewContext(xml);
 
8423
            if (!ctxt)
 
8424
                continue;
 
8425
 
 
8426
            state = virXPathString("string(/domainsnapshot/state)", ctxt);
 
8427
            if (state == NULL)
 
8428
                continue;
 
8429
            if (virXPathLong("string(/domainsnapshot/creationTime)", ctxt,
 
8430
                             &creation) < 0)
 
8431
                continue;
 
8432
            localtime_r(&creation, &time_info);
 
8433
            strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S %z", &time_info);
 
8434
 
 
8435
            vshPrint(ctl, " %-20s %-25s %s\n", names[i], timestr, state);
 
8436
        }
 
8437
    }
 
8438
 
 
8439
    ret = TRUE;
 
8440
 
 
8441
cleanup:
 
8442
    /* this frees up memory from the last iteration of the loop */
 
8443
    VIR_FREE(state);
 
8444
    if (snapshot)
 
8445
        virDomainSnapshotFree(snapshot);
 
8446
    xmlXPathFreeContext(ctxt);
 
8447
    if (xml)
 
8448
        xmlFreeDoc(xml);
 
8449
    VIR_FREE(doc);
 
8450
    VIR_FREE(names);
 
8451
    if (dom)
 
8452
        virDomainFree(dom);
 
8453
 
 
8454
    return ret;
 
8455
}
 
8456
 
 
8457
/*
 
8458
 * "snapshot-dumpxml" command
 
8459
 */
 
8460
static const vshCmdInfo info_snapshot_dumpxml[] = {
 
8461
    {"help", N_("Dump XML for a domain snapshot")},
 
8462
    {"desc", N_("Snapshot Dump XML")},
 
8463
    {NULL, NULL}
 
8464
};
 
8465
 
 
8466
static const vshCmdOptDef opts_snapshot_dumpxml[] = {
 
8467
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
8468
    {"snapshotname", VSH_OT_DATA, VSH_OFLAG_REQ, N_("snapshot name")},
 
8469
    {NULL, 0, 0, NULL}
 
8470
};
 
8471
 
 
8472
static int
 
8473
cmdSnapshotDumpXML(vshControl *ctl, const vshCmd *cmd)
 
8474
{
 
8475
    virDomainPtr dom = NULL;
 
8476
    int ret = FALSE;
 
8477
    char *name;
 
8478
    virDomainSnapshotPtr snapshot = NULL;
 
8479
    char *xml = NULL;
 
8480
 
 
8481
    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
 
8482
        goto cleanup;
 
8483
 
 
8484
    dom = vshCommandOptDomain(ctl, cmd, NULL);
 
8485
    if (dom == NULL)
 
8486
        goto cleanup;
 
8487
 
 
8488
    name = vshCommandOptString(cmd, "snapshotname", NULL);
 
8489
    if (name == NULL) {
 
8490
        vshError(ctl, "%s", _("missing snapshotname"));
 
8491
        goto cleanup;
 
8492
    }
 
8493
 
 
8494
    snapshot = virDomainSnapshotLookupByName(dom, name, 0);
 
8495
    if (snapshot == NULL)
 
8496
        goto cleanup;
 
8497
 
 
8498
    xml = virDomainSnapshotGetXMLDesc(snapshot, 0);
 
8499
    if (!xml)
 
8500
        goto cleanup;
 
8501
 
 
8502
    printf("%s", xml);
 
8503
 
 
8504
    ret = TRUE;
 
8505
 
 
8506
cleanup:
 
8507
    VIR_FREE(xml);
 
8508
    if (snapshot)
 
8509
        virDomainSnapshotFree(snapshot);
 
8510
    if (dom)
 
8511
        virDomainFree(dom);
 
8512
 
 
8513
    return ret;
 
8514
}
 
8515
 
 
8516
/*
 
8517
 * "snapshot-revert" command
 
8518
 */
 
8519
static const vshCmdInfo info_snapshot_revert[] = {
 
8520
    {"help", N_("Revert a domain to a snapshot")},
 
8521
    {"desc", N_("Revert domain to snapshot")},
 
8522
    {NULL, NULL}
 
8523
};
 
8524
 
 
8525
static const vshCmdOptDef opts_snapshot_revert[] = {
 
8526
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
8527
    {"snapshotname", VSH_OT_DATA, VSH_OFLAG_REQ, N_("snapshot name")},
 
8528
    {NULL, 0, 0, NULL}
 
8529
};
 
8530
 
 
8531
static int
 
8532
cmdDomainSnapshotRevert(vshControl *ctl, const vshCmd *cmd)
 
8533
{
 
8534
    virDomainPtr dom = NULL;
 
8535
    int ret = FALSE;
 
8536
    char *name;
 
8537
    virDomainSnapshotPtr snapshot = NULL;
 
8538
 
 
8539
    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
 
8540
        goto cleanup;
 
8541
 
 
8542
    dom = vshCommandOptDomain(ctl, cmd, NULL);
 
8543
    if (dom == NULL)
 
8544
        goto cleanup;
 
8545
 
 
8546
    name = vshCommandOptString(cmd, "snapshotname", NULL);
 
8547
    if (name == NULL) {
 
8548
        vshError(ctl, "%s", _("missing snapshotname"));
 
8549
        goto cleanup;
 
8550
    }
 
8551
 
 
8552
    snapshot = virDomainSnapshotLookupByName(dom, name, 0);
 
8553
    if (snapshot == NULL)
 
8554
        goto cleanup;
 
8555
 
 
8556
    if (virDomainRevertToSnapshot(snapshot, 0) < 0)
 
8557
        goto cleanup;
 
8558
 
 
8559
    ret = TRUE;
 
8560
 
 
8561
cleanup:
 
8562
    if (snapshot)
 
8563
        virDomainSnapshotFree(snapshot);
 
8564
    if (dom)
 
8565
        virDomainFree(dom);
 
8566
 
 
8567
    return ret;
 
8568
}
 
8569
 
 
8570
/*
 
8571
 * "snapshot-delete" command
 
8572
 */
 
8573
static const vshCmdInfo info_snapshot_delete[] = {
 
8574
    {"help", N_("Delete a domain snapshot")},
 
8575
    {"desc", N_("Snapshot Delete")},
 
8576
    {NULL, NULL}
 
8577
};
 
8578
 
 
8579
static const vshCmdOptDef opts_snapshot_delete[] = {
 
8580
    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
 
8581
    {"snapshotname", VSH_OT_DATA, VSH_OFLAG_REQ, N_("snapshot name")},
 
8582
    {"children", VSH_OT_BOOL, 0, N_("delete snapshot and all children")},
 
8583
    {NULL, 0, 0, NULL}
 
8584
};
 
8585
 
 
8586
static int
 
8587
cmdSnapshotDelete(vshControl *ctl, const vshCmd *cmd)
 
8588
{
 
8589
    virDomainPtr dom = NULL;
 
8590
    int ret = FALSE;
 
8591
    char *name;
 
8592
    virDomainSnapshotPtr snapshot = NULL;
 
8593
    unsigned int flags = 0;
 
8594
 
 
8595
    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
 
8596
        goto cleanup;
 
8597
 
 
8598
    dom = vshCommandOptDomain(ctl, cmd, NULL);
 
8599
    if (dom == NULL)
 
8600
        goto cleanup;
 
8601
 
 
8602
    name = vshCommandOptString(cmd, "snapshotname", NULL);
 
8603
    if (name == NULL) {
 
8604
        vshError(ctl, "%s", _("missing snapshotname"));
 
8605
        goto cleanup;
 
8606
    }
 
8607
 
 
8608
    if (vshCommandOptBool(cmd, "children"))
 
8609
        flags |= VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN;
 
8610
 
 
8611
    snapshot = virDomainSnapshotLookupByName(dom, name, 0);
 
8612
    if (snapshot == NULL)
 
8613
        goto cleanup;
 
8614
 
 
8615
    if (virDomainSnapshotDelete(snapshot, flags) < 0)
 
8616
        goto cleanup;
 
8617
 
 
8618
    ret = TRUE;
 
8619
 
 
8620
cleanup:
 
8621
    if (snapshot)
 
8622
        virDomainSnapshotFree(snapshot);
 
8623
    if (dom)
 
8624
        virDomainFree(dom);
 
8625
 
 
8626
    return ret;
 
8627
}
 
8628
 
 
8629
/*
7631
8630
 * Commands
7632
8631
 */
7633
8632
static const vshCmdDef commands[] = {
7675
8674
    {"hostname", cmdHostname, NULL, info_hostname},
7676
8675
    {"list", cmdList, opts_list, info_list},
7677
8676
    {"migrate", cmdMigrate, opts_migrate, info_migrate},
 
8677
    {"migrate-setmaxdowntime", cmdMigrateSetMaxDowntime, opts_migrate_setmaxdowntime, info_migrate_setmaxdowntime},
7678
8678
 
7679
8679
    {"net-autostart", cmdNetworkAutostart, opts_network_autostart, info_network_autostart},
7680
8680
    {"net-create", cmdNetworkCreate, opts_network_create, info_network_create},
7698
8698
    {"iface-start", cmdInterfaceStart, opts_interface_start, info_interface_start},
7699
8699
    {"iface-destroy", cmdInterfaceDestroy, opts_interface_destroy, info_interface_destroy},
7700
8700
 
 
8701
    {"managedsave", cmdManagedSave, opts_managedsave, info_managedsave},
 
8702
 
7701
8703
    {"nodeinfo", cmdNodeinfo, NULL, info_nodeinfo},
7702
8704
 
7703
8705
    {"nodedev-list", cmdNodeListDevices, opts_node_list_devices, info_node_list_devices},
7708
8710
    {"nodedev-create", cmdNodeDeviceCreate, opts_node_device_create, info_node_device_create},
7709
8711
    {"nodedev-destroy", cmdNodeDeviceDestroy, opts_node_device_destroy, info_node_device_destroy},
7710
8712
 
 
8713
    {"nwfilter-define", cmdNWFilterDefine, opts_nwfilter_define, info_nwfilter_define},
 
8714
    {"nwfilter-undefine", cmdNWFilterUndefine, opts_nwfilter_undefine, info_nwfilter_undefine},
 
8715
    {"nwfilter-dumpxml", cmdNWFilterDumpXML, opts_nwfilter_dumpxml, info_nwfilter_dumpxml},
 
8716
    {"nwfilter-list", cmdNWFilterList, opts_nwfilter_list, info_nwfilter_list},
 
8717
    {"nwfilter-edit", cmdNWFilterEdit, opts_nwfilter_edit, info_nwfilter_edit},
 
8718
 
7711
8719
    {"pool-autostart", cmdPoolAutostart, opts_pool_autostart, info_pool_autostart},
7712
8720
    {"pool-build", cmdPoolBuild, opts_pool_build, info_pool_build},
7713
8721
    {"pool-create", cmdPoolCreate, opts_pool_create, info_pool_create},
7738
8746
    {"pwd", cmdPwd, NULL, info_pwd},
7739
8747
#endif
7740
8748
    {"quit", cmdQuit, NULL, info_quit},
 
8749
    {"exit", cmdQuit, NULL, info_quit},
7741
8750
    {"reboot", cmdReboot, opts_reboot, info_reboot},
7742
8751
    {"restore", cmdRestore, opts_restore, info_restore},
7743
8752
    {"resume", cmdResume, opts_resume, info_resume},
7751
8760
    {"suspend", cmdSuspend, opts_suspend, info_suspend},
7752
8761
    {"ttyconsole", cmdTTYConsole, opts_ttyconsole, info_ttyconsole},
7753
8762
    {"undefine", cmdUndefine, opts_undefine, info_undefine},
 
8763
    {"update-device", cmdUpdateDevice, opts_update_device, info_update_device},
7754
8764
    {"uri", cmdURI, NULL, info_uri},
7755
8765
 
7756
8766
    {"vol-create", cmdVolCreate, opts_vol_create, info_vol_create},
7758
8768
    {"vol-create-as", cmdVolCreateAs, opts_vol_create_as, info_vol_create_as},
7759
8769
    {"vol-clone", cmdVolClone, opts_vol_clone, info_vol_clone},
7760
8770
    {"vol-delete", cmdVolDelete, opts_vol_delete, info_vol_delete},
 
8771
    {"vol-wipe", cmdVolWipe, opts_vol_wipe, info_vol_wipe},
7761
8772
    {"vol-dumpxml", cmdVolDumpXML, opts_vol_dumpxml, info_vol_dumpxml},
7762
8773
    {"vol-info", cmdVolInfo, opts_vol_info, info_vol_info},
7763
8774
    {"vol-list", cmdVolList, opts_vol_list, info_vol_list},
7769
8780
    {"vcpupin", cmdVcpupin, opts_vcpupin, info_vcpupin},
7770
8781
    {"version", cmdVersion, NULL, info_version},
7771
8782
    {"vncdisplay", cmdVNCDisplay, opts_vncdisplay, info_vncdisplay},
 
8783
 
 
8784
    {"snapshot-create", cmdSnapshotCreate, opts_snapshot_create, info_snapshot_create},
 
8785
    {"snapshot-current", cmdSnapshotCurrent, opts_snapshot_current, info_snapshot_current},
 
8786
    {"snapshot-delete", cmdSnapshotDelete, opts_snapshot_delete, info_snapshot_delete},
 
8787
    {"snapshot-dumpxml", cmdSnapshotDumpXML, opts_snapshot_dumpxml, info_snapshot_dumpxml},
 
8788
    {"snapshot-list", cmdSnapshotList, opts_snapshot_list, info_snapshot_list},
 
8789
    {"snapshot-revert", cmdDomainSnapshotRevert, opts_snapshot_revert, info_snapshot_revert},
 
8790
 
7772
8791
    {NULL, NULL, NULL, NULL}
7773
8792
};
7774
8793
 
7869
8888
        vshError(ctl, _("command '%s' doesn't exist"), cmdname);
7870
8889
        return FALSE;
7871
8890
    } else {
7872
 
        const char *desc = N_(vshCmddefGetInfo(def, "desc"));
7873
 
        const char *help = N_(vshCmddefGetInfo(def, "help"));
 
8891
        const char *desc = _(vshCmddefGetInfo(def, "desc"));
 
8892
        const char *help = _(vshCmddefGetInfo(def, "help"));
7874
8893
        char buf[256];
7875
8894
 
7876
8895
        fputs(_("  NAME\n"), stdout);
7885
8904
                if (opt->type == VSH_OT_BOOL)
7886
8905
                    fmt = "[--%s]";
7887
8906
                else if (opt->type == VSH_OT_INT)
7888
 
                    fmt = N_("[--%s <number>]");
 
8907
                    /* xgettext:c-format */
 
8908
                    fmt = _("[--%s <number>]");
7889
8909
                else if (opt->type == VSH_OT_STRING)
7890
 
                    fmt = N_("[--%s <string>]");
 
8910
                    /* xgettext:c-format */
 
8911
                    fmt = _("[--%s <string>]");
7891
8912
                else if (opt->type == VSH_OT_DATA)
7892
8913
                    fmt = ((opt->flag & VSH_OFLAG_REQ) ? "<%s>" : "[<%s>]");
7893
8914
                else
7894
8915
                    assert(0);
7895
8916
                fputc(' ', stdout);
7896
 
                fprintf(stdout, _(fmt), opt->name);
 
8917
                fprintf(stdout, fmt, opt->name);
7897
8918
            }
7898
8919
        }
7899
8920
        fputc('\n', stdout);
7917
8938
                else if (opt->type == VSH_OT_DATA)
7918
8939
                    snprintf(buf, sizeof(buf), "<%s>", opt->name);
7919
8940
 
7920
 
                fprintf(stdout, "    %-15s  %s\n", buf, N_(opt->help));
 
8941
                fprintf(stdout, "    %-15s  %s\n", buf, _(opt->help));
7921
8942
            }
7922
8943
        }
7923
8944
        fputc('\n', stdout);
8012
9033
    return arg && arg->data && *arg->data ? arg->data : NULL;
8013
9034
}
8014
9035
 
 
9036
/*
 
9037
 * Returns option as long long
 
9038
 */
 
9039
static long long
 
9040
vshCommandOptLongLong(const vshCmd *cmd, const char *name, int *found)
 
9041
{
 
9042
    vshCmdOpt *arg = vshCommandOpt(cmd, name);
 
9043
    int num_found = FALSE;
 
9044
    long long res = 0;
 
9045
    char *end_p = NULL;
 
9046
 
 
9047
    if ((arg != NULL) && (arg->data != NULL))
 
9048
        num_found = !virStrToLong_ll(arg->data, &end_p, 10, &res);
 
9049
    if (found)
 
9050
        *found = num_found;
 
9051
    return res;
 
9052
}
 
9053
 
8015
9054
#if 0
8016
9055
static int
8017
9056
vshCommandOptStringList(const vshCmd *cmd, const char *name, char ***data)
8159
9198
    return network;
8160
9199
}
8161
9200
 
 
9201
 
 
9202
static virNWFilterPtr
 
9203
vshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd,
 
9204
                        char **name, int flag)
 
9205
{
 
9206
    virNWFilterPtr nwfilter = NULL;
 
9207
    char *n;
 
9208
    const char *optname = "nwfilter";
 
9209
    if (!cmd_has_option (ctl, cmd, optname))
 
9210
        return NULL;
 
9211
 
 
9212
    if (!(n = vshCommandOptString(cmd, optname, NULL))) {
 
9213
        vshError(ctl, "%s", _("undefined nwfilter name"));
 
9214
        return NULL;
 
9215
    }
 
9216
 
 
9217
    vshDebug(ctl, 5, "%s: found option <%s>: %s\n",
 
9218
             cmd->def->name, optname, n);
 
9219
 
 
9220
    if (name)
 
9221
        *name = n;
 
9222
 
 
9223
    /* try it by UUID */
 
9224
    if ((flag & VSH_BYUUID) && (strlen(n) == VIR_UUID_STRING_BUFLEN-1)) {
 
9225
        vshDebug(ctl, 5, "%s: <%s> trying as nwfilter UUID\n",
 
9226
                 cmd->def->name, optname);
 
9227
        nwfilter = virNWFilterLookupByUUIDString(ctl->conn, n);
 
9228
    }
 
9229
    /* try it by NAME */
 
9230
    if (nwfilter == NULL && (flag & VSH_BYNAME)) {
 
9231
        vshDebug(ctl, 5, "%s: <%s> trying as nwfilter NAME\n",
 
9232
                 cmd->def->name, optname);
 
9233
        nwfilter = virNWFilterLookupByName(ctl->conn, n);
 
9234
    }
 
9235
 
 
9236
    if (!nwfilter)
 
9237
        vshError(ctl, _("failed to get nwfilter '%s'"), n);
 
9238
 
 
9239
    return nwfilter;
 
9240
}
 
9241
 
8162
9242
static virInterfacePtr
8163
9243
vshCommandOptInterfaceBy(vshControl *ctl, const vshCmd *cmd,
8164
9244
                         char **name, int flag)
8332
9412
    while (cmd) {
8333
9413
        struct timeval before, after;
8334
9414
 
 
9415
        if ((ctl->conn == NULL) || (disconnected != 0))
 
9416
            vshReconnect(ctl);
 
9417
 
8335
9418
        if (ctl->timing)
8336
9419
            GETTIMEOFDAY(&before);
8337
9420
 
8343
9426
        if (ret == FALSE)
8344
9427
            virshReportError(ctl);
8345
9428
 
 
9429
        /* try to automatically catch disconnections */
 
9430
        if ((ret == FALSE) &&
 
9431
            ((disconnected != 0) ||
 
9432
             ((last_error != NULL) &&
 
9433
              (((last_error->code == VIR_ERR_SYSTEM_ERROR) &&
 
9434
                (last_error->domain == VIR_FROM_REMOTE)) ||
 
9435
               (last_error->code == VIR_ERR_RPC) ||
 
9436
               (last_error->code == VIR_ERR_NO_CONNECT) ||
 
9437
               (last_error->code == VIR_ERR_INVALID_CONN)))))
 
9438
            vshReconnect(ctl);
 
9439
 
8346
9440
        if (STREQ(cmd->def->name, "quit"))        /* hack ... */
8347
9441
            return ret;
8348
9442
 
8572
9666
    return TRUE;
8573
9667
 
8574
9668
 syntaxError:
8575
 
    if (ctl->cmd)
 
9669
    if (ctl->cmd) {
8576
9670
        vshCommandFree(ctl->cmd);
 
9671
        ctl->cmd = NULL;
 
9672
    }
8577
9673
    if (first)
8578
9674
        vshCommandOptFree(first);
8579
9675
    VIR_FREE(tkdata);
8590
9686
{
8591
9687
    switch (state) {
8592
9688
    case VIR_DOMAIN_RUNNING:
8593
 
        return gettext_noop("running");
 
9689
        return N_("running");
8594
9690
    case VIR_DOMAIN_BLOCKED:
8595
 
        return gettext_noop("idle");
 
9691
        return N_("idle");
8596
9692
    case VIR_DOMAIN_PAUSED:
8597
 
        return gettext_noop("paused");
 
9693
        return N_("paused");
8598
9694
    case VIR_DOMAIN_SHUTDOWN:
8599
 
        return gettext_noop("in shutdown");
 
9695
        return N_("in shutdown");
8600
9696
    case VIR_DOMAIN_SHUTOFF:
8601
 
        return gettext_noop("shut off");
 
9697
        return N_("shut off");
8602
9698
    case VIR_DOMAIN_CRASHED:
8603
 
        return gettext_noop("crashed");
 
9699
        return N_("crashed");
8604
9700
    default:
8605
9701
        ;/*FALLTHROUGH*/
8606
9702
    }
8607
 
    return gettext_noop("no state");  /* = dom0 state */
 
9703
    return N_("no state");  /* = dom0 state */
8608
9704
}
8609
9705
 
8610
9706
static const char *
8612
9708
{
8613
9709
    switch (state) {
8614
9710
    case VIR_VCPU_OFFLINE:
8615
 
        return gettext_noop("offline");
 
9711
        return N_("offline");
8616
9712
    case VIR_VCPU_BLOCKED:
8617
 
        return gettext_noop("idle");
 
9713
        return N_("idle");
8618
9714
    case VIR_VCPU_RUNNING:
8619
 
        return gettext_noop("running");
 
9715
        return N_("running");
8620
9716
    default:
8621
9717
        ;/*FALLTHROUGH*/
8622
9718
    }
8623
 
    return gettext_noop("no state");
 
9719
    return N_("no state");
8624
9720
}
8625
9721
 
8626
9722
static int
8673
9769
{
8674
9770
    va_list ap;
8675
9771
 
8676
 
    va_start(ap, format);
8677
 
    vshOutputLogFile(ctl, VSH_ERR_ERROR, format, ap);
8678
 
    va_end(ap);
 
9772
    if (ctl != NULL) {
 
9773
        va_start(ap, format);
 
9774
        vshOutputLogFile(ctl, VSH_ERR_ERROR, format, ap);
 
9775
        va_end(ap);
 
9776
    }
8679
9777
 
8680
9778
    fputs(_("error: "), stderr);
8681
9779
 
8751
9849
    /* set up the library error handler */
8752
9850
    virSetErrorFunc(NULL, virshErrorHandler);
8753
9851
 
 
9852
    /* set up the signals handlers to catch disconnections */
 
9853
    vshSetupSignals();
 
9854
 
8754
9855
    ctl->conn = virConnectOpenAuth(ctl->name,
8755
9856
                                   virConnectAuthPtrDefault,
8756
9857
                                   ctl->readonly ? VIR_CONNECT_RO : 0);
8770
9871
}
8771
9872
 
8772
9873
#ifndef O_SYNC
8773
 
#define O_SYNC 0
 
9874
# define O_SYNC 0
8774
9875
#endif
8775
9876
#define LOGFILE_FLAGS (O_WRONLY | O_APPEND | O_CREAT | O_SYNC)
8776
9877
 
9148
10249
 
9149
10250
    for (cmd = commands; cmd->name; cmd++)
9150
10251
        fprintf(stdout,
9151
 
                "    %-15s %s\n", cmd->name, N_(vshCmddefGetInfo(cmd,
9152
 
                                                                 "help")));
 
10252
                "    %-15s %s\n", cmd->name, _(vshCmddefGetInfo(cmd, "help")));
9153
10253
 
9154
10254
    fprintf(stdout, "%s",
9155
10255
            _("\n  (specify help <command> for details about the command)\n\n"));