~ubuntu-branches/ubuntu/trusty/virtualbox-ose/trusty

« back to all changes in this revision

Viewing changes to src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-12-18 16:44:29 UTC
  • mfrom: (0.3.3 upstream) (0.4.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091218164429-jd34ccexpv5na11a
Tags: 3.1.2-dfsg-1ubuntu1
* Merge from Debian unstable (LP: #498219), remaining changes:
  - Disable update action
    - debian/patches/u01-disable-update-action.dpatch
  - VirtualBox should go in Accessories, not in System tools (LP: #288590)
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Add Launchpad integration
    - debian/control
    - debian/lpi-bug.xpm
    - debian/patches/u02-lp-integration.dpatch
* Fixes the following bugs:
  - Kernel module fails to build with Linux >= 2.6.32 (LP: #474625)
  - X.Org drivers need to be rebuilt against X-Server 1.7 (LP: #495935)
  - The *-source packages try to build the kernel modules even though the
    kernel headers aren't available (LP: #473334)
* Replace *-source packages with transitional packages for *-dkms.
* Adapt u01-disable-update-action.dpatch and u02-lp-integration.dpatch for
  new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
157
157
                "       of a container can be registered.\n"
158
158
                "\n"
159
159
                : "",
 
160
            (u64Cmd & USAGE_DUMPHDINFO) ?
 
161
                "  dumphdinfo <filepath>\n"
 
162
                "       Prints information about the image at the given location.\n"
 
163
                "\n"
 
164
                : "",
160
165
            (u64Cmd & USAGE_LISTPARTITIONS) ?
161
166
                "  listpartitions -rawdisk <diskname>\n"
162
167
                "       Lists all partitions on <diskname>.\n"
437
442
    /* offDelta */
438
443
    if (argc >= 3)
439
444
    {
440
 
        int rc = RTStrToInt64Ex(argv[2], NULL, 0, &offDelta);
441
 
        if (RT_FAILURE(rc))
 
445
        int irc = RTStrToInt64Ex(argv[2], NULL, 0, &offDelta);
 
446
        if (RT_FAILURE(irc))
442
447
            return errorArgument(argv[0], "Failed to read delta '%s', rc=%Rrc\n", argv[2], rc);
443
448
    }
444
449
 
449
454
    /* ModuleAddress */
450
455
    if (argc >= 5)
451
456
    {
452
 
        int rc = RTStrToUInt64Ex(argv[4], NULL, 0, &ModuleAddress);
453
 
        if (RT_FAILURE(rc))
 
457
        int irc = RTStrToUInt64Ex(argv[4], NULL, 0, &ModuleAddress);
 
458
        if (RT_FAILURE(irc))
454
459
            return errorArgument(argv[0], "Failed to read module address '%s', rc=%Rrc\n", argv[4], rc);
455
460
    }
456
461
 
457
462
    /* ModuleSize */
458
463
    if (argc >= 6)
459
464
    {
460
 
        int rc = RTStrToUInt64Ex(argv[5], NULL, 0, &ModuleSize);
461
 
        if (RT_FAILURE(rc))
 
465
        int irc = RTStrToUInt64Ex(argv[5], NULL, 0, &ModuleSize);
 
466
        if (RT_FAILURE(irc))
462
467
            return errorArgument(argv[0], "Failed to read module size '%s', rc=%Rrc\n", argv[5], rc);
463
468
    }
464
469
 
468
473
    Utf8Str KeyStr;
469
474
    HRESULT hrc = NewUniqueKey(machine, "VBoxInternal/DBGF/loadsyms", KeyStr);
470
475
    if (SUCCEEDED(hrc))
471
 
        hrc = SetString(machine, "VBoxInternal/DBGF/loadsyms", KeyStr, "Filename", pszFilename);
 
476
        hrc = SetString(machine, "VBoxInternal/DBGF/loadsyms", KeyStr.c_str(), "Filename", pszFilename);
472
477
    if (SUCCEEDED(hrc) && argc >= 3)
473
 
        hrc = SetInt64(machine, "VBoxInternal/DBGF/loadsyms", KeyStr, "Delta", offDelta);
 
478
        hrc = SetInt64(machine, "VBoxInternal/DBGF/loadsyms", KeyStr.c_str(), "Delta", offDelta);
474
479
    if (SUCCEEDED(hrc) && argc >= 4)
475
 
        hrc = SetString(machine, "VBoxInternal/DBGF/loadsyms", KeyStr, "Module", pszModule);
 
480
        hrc = SetString(machine, "VBoxInternal/DBGF/loadsyms", KeyStr.c_str(), "Module", pszModule);
476
481
    if (SUCCEEDED(hrc) && argc >= 5)
477
 
        hrc = SetUInt64(machine, "VBoxInternal/DBGF/loadsyms", KeyStr, "ModuleAddress", ModuleAddress);
 
482
        hrc = SetUInt64(machine, "VBoxInternal/DBGF/loadsyms", KeyStr.c_str(), "ModuleAddress", ModuleAddress);
478
483
    if (SUCCEEDED(hrc) && argc >= 6)
479
 
        hrc = SetUInt64(machine, "VBoxInternal/DBGF/loadsyms", KeyStr, "ModuleSize", ModuleSize);
 
484
        hrc = SetUInt64(machine, "VBoxInternal/DBGF/loadsyms", KeyStr.c_str(), "ModuleSize", ModuleSize);
480
485
 
481
486
    return FAILED(hrc);
482
487
}
490
495
    RTPrintf("Error code %Rrc at %s(%u) in function %s\n", rc, RT_SRC_POS_ARGS);
491
496
}
492
497
 
493
 
static int handleSetHDUUID(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
 
498
static int CmdSetHDUUID(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
494
499
{
495
500
    /* we need exactly one parameter: the image file */
496
501
    if (argc != 1)
504
509
 
505
510
    /* just try it */
506
511
    char *pszFormat = NULL;
507
 
    int rc = VDGetFormat(argv[0], &pszFormat);
 
512
    int rc = VDGetFormat(NULL, argv[0], &pszFormat);
508
513
    if (RT_FAILURE(rc))
509
514
    {
510
515
        RTPrintf("Format autodetect failed: %Rrc\n", rc);
519
524
    vdInterfaceErrorCallbacks.cbSize       = sizeof(VDINTERFACEERROR);
520
525
    vdInterfaceErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR;
521
526
    vdInterfaceErrorCallbacks.pfnError     = handleVDError;
 
527
    vdInterfaceErrorCallbacks.pfnMessage   = NULL;
522
528
 
523
529
    rc = VDInterfaceAdd(&vdInterfaceError, "VBoxManage_IError", VDINTERFACETYPE_ERROR,
524
530
                        &vdInterfaceErrorCallbacks, NULL, &pVDIfs);
550
556
    return RT_FAILURE(rc);
551
557
}
552
558
 
 
559
 
 
560
static int handleVDMessage(void *pvUser, const char *pszFormat, ...)
 
561
{
 
562
    NOREF(pvUser);
 
563
    va_list args;
 
564
    va_start(args, pszFormat);
 
565
    int rc = RTPrintfV(pszFormat, args);
 
566
    va_end(args);
 
567
    return rc;
 
568
}
 
569
 
 
570
static int CmdDumpHDInfo(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
 
571
{
 
572
    /* we need exactly one parameter: the image file */
 
573
    if (argc != 1)
 
574
    {
 
575
        return errorSyntax(USAGE_SETHDUUID, "Not enough parameters");
 
576
    }
 
577
 
 
578
    /* just try it */
 
579
    char *pszFormat = NULL;
 
580
    int rc = VDGetFormat(NULL, argv[0], &pszFormat);
 
581
    if (RT_FAILURE(rc))
 
582
    {
 
583
        RTPrintf("Format autodetect failed: %Rrc\n", rc);
 
584
        return 1;
 
585
    }
 
586
 
 
587
    PVBOXHDD pDisk = NULL;
 
588
 
 
589
    PVDINTERFACE     pVDIfs = NULL;
 
590
    VDINTERFACE      vdInterfaceError;
 
591
    VDINTERFACEERROR vdInterfaceErrorCallbacks;
 
592
    vdInterfaceErrorCallbacks.cbSize       = sizeof(VDINTERFACEERROR);
 
593
    vdInterfaceErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR;
 
594
    vdInterfaceErrorCallbacks.pfnError     = handleVDError;
 
595
    vdInterfaceErrorCallbacks.pfnMessage   = handleVDMessage;
 
596
 
 
597
    rc = VDInterfaceAdd(&vdInterfaceError, "VBoxManage_IError", VDINTERFACETYPE_ERROR,
 
598
                        &vdInterfaceErrorCallbacks, NULL, &pVDIfs);
 
599
    AssertRC(rc);
 
600
 
 
601
    rc = VDCreate(pVDIfs, &pDisk);
 
602
    if (RT_FAILURE(rc))
 
603
    {
 
604
        RTPrintf("Error while creating the virtual disk container: %Rrc\n", rc);
 
605
        return 1;
 
606
    }
 
607
 
 
608
    /* Open the image */
 
609
    rc = VDOpen(pDisk, pszFormat, argv[0], VD_OPEN_FLAGS_NORMAL, NULL);
 
610
    if (RT_FAILURE(rc))
 
611
    {
 
612
        RTPrintf("Error while opening the image: %Rrc\n", rc);
 
613
        return 1;
 
614
    }
 
615
 
 
616
    VDDumpImages(pDisk);
 
617
 
 
618
    VDCloseAll(pDisk);
 
619
 
 
620
    return RT_FAILURE(rc);
 
621
}
 
622
 
553
623
static int partRead(RTFILE File, PHOSTPARTITIONS pPart)
554
624
{
555
625
    uint8_t aBuffer[512];
753
823
        return errorSyntax(USAGE_LISTPARTITIONS, "Mandatory parameter -rawdisk missing");
754
824
 
755
825
    RTFILE RawFile;
756
 
    int vrc = RTFileOpen(&RawFile, rawdisk.raw(), RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
 
826
    int vrc = RTFileOpen(&RawFile, rawdisk.raw(), RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
757
827
    if (RT_FAILURE(vrc))
758
828
    {
759
829
        RTPrintf("Error opening the raw disk: %Rrc\n", vrc);
873
943
    fRelative = true;
874
944
#endif /* RT_OS_DARWIN */
875
945
    RTFILE RawFile;
876
 
    int vrc = RTFileOpen(&RawFile, rawdisk.raw(), RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
 
946
    int vrc = RTFileOpen(&RawFile, rawdisk.raw(), RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
877
947
    if (RT_FAILURE(vrc))
878
948
    {
879
949
        RTPrintf("Error opening the raw disk '%s': %Rrc\n", rawdisk.raw(), vrc);
1200
1270
                    &&  pszMBRFilename)
1201
1271
                {
1202
1272
                    RTFILE MBRFile;
1203
 
                    vrc = RTFileOpen(&MBRFile, pszMBRFilename, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
 
1273
                    vrc = RTFileOpen(&MBRFile, pszMBRFilename, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
1204
1274
                    if (RT_FAILURE(vrc))
1205
1275
                    {
1206
1276
                        RTPrintf("Cannot open replacement MBR file '%s' specified with -mbr: %Rrc\n", pszMBRFilename, vrc);
1226
1296
    vdInterfaceErrorCallbacks.cbSize       = sizeof(VDINTERFACEERROR);
1227
1297
    vdInterfaceErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR;
1228
1298
    vdInterfaceErrorCallbacks.pfnError     = handleVDError;
 
1299
    vdInterfaceErrorCallbacks.pfnMessage   = NULL;
1229
1300
 
1230
1301
    vrc = VDInterfaceAdd(&vdInterfaceError, "VBoxManage_IError", VDINTERFACETYPE_ERROR,
1231
1302
                         &vdInterfaceErrorCallbacks, NULL, &pVDIfs);
1280
1351
 
1281
1352
    if (fRegister)
1282
1353
    {
1283
 
        ComPtr<IHardDisk> hardDisk;
 
1354
        ComPtr<IMedium> hardDisk;
1284
1355
        CHECK_ERROR(aVirtualBox, OpenHardDisk(filename, AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam()));
1285
1356
    }
1286
1357
 
1335
1406
    vdInterfaceErrorCallbacks.cbSize       = sizeof(VDINTERFACEERROR);
1336
1407
    vdInterfaceErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR;
1337
1408
    vdInterfaceErrorCallbacks.pfnError     = handleVDError;
 
1409
    vdInterfaceErrorCallbacks.pfnMessage   = NULL;
1338
1410
 
1339
1411
    int vrc = VDInterfaceAdd(&vdInterfaceError, "VBoxManage_IError", VDINTERFACETYPE_ERROR,
1340
1412
                             &vdInterfaceErrorCallbacks, NULL, &pVDIfs);
1416
1488
    vdInterfaceErrorCallbacks.cbSize       = sizeof(VDINTERFACEERROR);
1417
1489
    vdInterfaceErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR;
1418
1490
    vdInterfaceErrorCallbacks.pfnError     = handleVDError;
 
1491
    vdInterfaceErrorCallbacks.pfnMessage   = NULL;
1419
1492
 
1420
1493
    int vrc = VDInterfaceAdd(&vdInterfaceError, "VBoxManage_IError", VDINTERFACETYPE_ERROR,
1421
1494
                             &vdInterfaceErrorCallbacks, NULL, &pVDIfs);
1434
1507
    if (fWriteToStdOut)
1435
1508
        outFile = 1;
1436
1509
    else
1437
 
        vrc = RTFileOpen(&outFile, Utf8Str(dst).raw(), RTFILE_O_OPEN | RTFILE_O_CREATE | RTFILE_O_WRITE | RTFILE_O_DENY_ALL);
 
1510
        vrc = RTFileOpen(&outFile, Utf8Str(dst).raw(), RTFILE_O_WRITE | RTFILE_O_CREATE | RTFILE_O_DENY_ALL);
1438
1511
    if (RT_FAILURE(vrc))
1439
1512
    {
1440
1513
        VDCloseAll(pDisk);
1445
1518
    if (srcformat.isEmpty())
1446
1519
    {
1447
1520
        char *pszFormat = NULL;
1448
 
        vrc = VDGetFormat(Utf8Str(src).raw(), &pszFormat);
 
1521
        vrc = VDGetFormat(NULL, Utf8Str(src).raw(), &pszFormat);
1449
1522
        if (RT_FAILURE(vrc))
1450
1523
        {
1451
1524
            VDCloseAll(pDisk);
1580
1653
    vdInterfaceErrorCallbacks.cbSize       = sizeof(VDINTERFACEERROR);
1581
1654
    vdInterfaceErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR;
1582
1655
    vdInterfaceErrorCallbacks.pfnError     = handleVDError;
 
1656
    vdInterfaceErrorCallbacks.pfnMessage   = NULL;
1583
1657
 
1584
1658
    vrc = VDInterfaceAdd(&vdInterfaceError, "VBoxManage_IError", VDINTERFACETYPE_ERROR,
1585
1659
                         &vdInterfaceErrorCallbacks, NULL, &pVDIfs);
1591
1665
        if (srcformat.isEmpty())
1592
1666
        {
1593
1667
            char *pszFormat = NULL;
1594
 
            vrc = VDGetFormat(Utf8Str(src).raw(), &pszFormat);
 
1668
            vrc = VDGetFormat(NULL, Utf8Str(src).raw(), &pszFormat);
1595
1669
            if (RT_FAILURE(vrc))
1596
1670
            {
1597
1671
                RTPrintf("No file format specified and autodetect failed - please specify format: %Rrc\n", vrc);
1702
1776
    //if (!strcmp(pszCmd, "unloadsyms"))
1703
1777
    //    return CmdUnloadSyms(argc - 1 , &a->argv[1]);
1704
1778
    if (!strcmp(pszCmd, "sethduuid") || !strcmp(pszCmd, "setvdiuuid"))
1705
 
        return handleSetHDUUID(a->argc - 1, &a->argv[1], a->virtualBox, a->session);
 
1779
        return CmdSetHDUUID(a->argc - 1, &a->argv[1], a->virtualBox, a->session);
 
1780
    if (!strcmp(pszCmd, "dumphdinfo"))
 
1781
        return CmdDumpHDInfo(a->argc - 1, &a->argv[1], a->virtualBox, a->session);
1706
1782
    if (!strcmp(pszCmd, "listpartitions"))
1707
1783
        return CmdListPartitions(a->argc - 1, &a->argv[1], a->virtualBox, a->session);
1708
1784
    if (!strcmp(pszCmd, "createrawvmdk"))