- Timestamp:
- Apr 4, 2007 9:41:12 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r1551 r1916 442 442 { 443 443 RTPrintf("VBoxManage convertdd <filename> <outputfile>\n" 444 "VBoxManage convertdd stdin <outputfile> <bytes>\n" 444 445 "\n"); 445 446 } … … 2327 2328 } 2328 2329 2329 static int handleConvertDDImage(int argc, char *argv[], 2330 ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session) 2330 static int handleConvertDDImage(int argc, char *argv[]) 2331 2331 { 2332 if (argc != 2) 2333 { 2332 #ifdef __LINUX__ 2333 const bool fReadFromStdIn = !strcmp(argv[0], "stdin"); 2334 #else 2335 const bool fReadFromStdIn = false; 2336 #endif 2337 2338 if ((!fReadFromStdIn && argc != 2) || (fReadFromStdIn && argc != 3)) 2334 2339 return errorSyntax(USAGE_CONVERTDD, "Incorrect number of parameters"); 2335 }2336 2337 2340 2338 2341 RTPrintf("Converting VDI: from DD image file=\"%s\" to file=\"%s\"...\n", … … 2341 2344 /* open raw image file. */ 2342 2345 RTFILE File; 2343 int rc = RTFileOpen(&File, argv[0], RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE); 2346 int rc = VINF_SUCCESS; 2347 if (fReadFromStdIn) 2348 File = 0; 2349 else 2350 rc = RTFileOpen(&File, argv[0], RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE); 2344 2351 if (VBOX_FAILURE(rc)) 2345 2352 { … … 2348 2355 } 2349 2356 2357 uint64_t cbFile; 2350 2358 /* get image size. */ 2351 uint64_t cbFile; 2352 rc = RTFileGetSize(File, &cbFile); 2359 if (fReadFromStdIn) 2360 cbFile = RTStrToUInt64(argv[2]); 2361 else 2362 rc = RTFileGetSize(File, &cbFile); 2353 2363 if (VBOX_SUCCESS(rc)) 2354 2364 { 2355 RTPrintf("Creating fixed image with size %u Bytes...\n", (unsigned)cbFile); 2365 RTPrintf("Creating fixed image with size %RU64Bytes (%RU64MB)...\n", cbFile, (cbFile + _1M - 1) / _1M); 2366 char pszComment[256]; 2367 RTStrPrintf(pszComment, sizeof(pszComment), "Converted image from %s", argv[0]); 2356 2368 rc = VDICreateBaseImage(argv[1], 2357 2369 VDI_IMAGE_TYPE_FIXED, 2358 2370 cbFile, 2359 "Converted from DD test image", NULL, NULL);2371 pszComment, NULL, NULL); 2360 2372 if (VBOX_SUCCESS(rc)) 2361 2373 { … … 2396 2408 } 2397 2409 } 2410 else 2411 RTPrintf("Failed to create output file (%Vrc)!\n", rc); 2398 2412 } 2399 2413 RTFileClose(File); … … 6094 6108 //////////////////////////////////////////////////////////////////////////// 6095 6109 6096 /* update settings command (no VirtualBox instantiation!) */6110 /* update settings command (no VirtualBox instantiation!) */ 6097 6111 if (argc >= 2 && (strcmp(argv[1], "updatesettings") == 0)) 6098 6112 { 6099 rc = handleUpdateSettings(argc - 2 , argv + 2); 6113 rc = handleUpdateSettings(argc - 2, argv + 2); 6114 break; 6115 } 6116 6117 /* convertdd: does not need a VirtualBox instantiation) */ 6118 if (argc >= 2 && (strcmp(argv[1], "convertdd") == 0)) 6119 { 6120 rc = handleConvertDDImage(argc - 2, argv + 2); 6100 6121 break; 6101 6122 } … … 6146 6167 { "modifyvm", handleModifyVM }, 6147 6168 { "clonevdi", handleCloneVDI }, 6148 { "convertdd", handleConvertDDImage },6149 6169 { "startvm", handleStartVM }, 6150 6170 { "controlvm", handleControlVM },
Note:
See TracChangeset
for help on using the changeset viewer.