Date: Thu, 3 Mar 2011 18:51:00 GMT From: Dmitry Pryanishnikov <lynx.ripe@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/155236: [patch] emulators/virtualbox-ose: enable createrawvmdk -relative under FreeBSD Message-ID: <201103031851.p23Ip0Yd059319@red.freebsd.org> Resent-Message-ID: <201103031900.p23J0NCY009534@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 155236 >Category: ports >Synopsis: [patch] emulators/virtualbox-ose: enable createrawvmdk -relative under FreeBSD >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Mar 03 19:00:23 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Dmitry Pryanishnikov >Release: 8.2-PRERELEASE >Organization: Home >Environment: FreeBSD lynx.homenet 8.2-PRERELEASE FreeBSD 8.2-PRERELEASE #0: Fri Feb 25 14:49:51 EET 2011 dmitry@lynx.homenet:/databig/obj/databig/ftp/RELENG_8/src.110219/sys/lynx amd64 >Description: The use of 'VBoxManage internalcommands createrawvmdk ... -relative' command is currently limited to Linux hosts. This command is useful when one wants to run the secondary OS on the system HDD (e.g. Linux) inside the VirtualBox without giving it the full access to the HDD. It creates the .vmdk-file which directs HDD access to the separate partition devices (e.g. /dev/sda1 instead of /dev/sda under Linux). This allows to give an access for the VirtualBox user to those partition devices only, thus preventing the accidental data loss on the rest of the HDD. Hovewer, naming of those partition devices under FreeBSD is quite similar to that under Linux (Linux: /dev/sda -> /dev/sda1..., FreeBSD: /dev/ada0 -> /dev/ada0s1...). This allows to make this feature available to the FreeBSD users via an attached (rather trivial) patch. The patch is verified using the following command: VBoxManage internalcommands createrawvmdk -filename ada0s4,8,9.vmdk -rawdisk /dev/ada0 -partitions 4,8,9 -relative and then installing the Gentoo Linux/amd64 inside it, then rebooting the host into the resuling OS and verifying that the system is installed correctly. >How-To-Repeat: >Fix: Patch attached with submission follows: --- src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp.orig 2010-12-01 19:09:24.000000000 +0200 +++ src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp 2011-03-01 15:57:46.145416771 +0200 @@ -178,7 +178,7 @@ " (the partitioning information in the MBR file is ignored).\n" " The diskname is on Linux e.g. /dev/sda, and on Windows e.g.\n" " \\\\.\\PhysicalDrive0).\n" - " On Linux host the parameter -relative causes a VMDK file to be created\n" + " On Linux or FreeBSD host the parameter -relative causes a VMDK file to be created\n" " which refers to individual partitions instead to the entire disk.\n" " Optionally the created image can be immediately registered.\n" " The necessary partition numbers can be queried with\n" @@ -926,12 +926,12 @@ { fRegister = true; } -#ifdef RT_OS_LINUX +#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) else if (strcmp(argv[i], "-relative") == 0) { fRelative = true; } -#endif /* RT_OS_LINUX */ +#endif /* RT_OS_LINUX || RT_OS_FREEBSD */ else { return errorSyntax(USAGE_CREATERAWVMDK, "Invalid parameter '%s'", Utf8Str(argv[i]).raw()); @@ -1280,10 +1280,16 @@ { if (fRelative) { -#ifdef RT_OS_LINUX +#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) /* Refer to the correct partition and use offset 0. */ char *psz; - vrc = RTStrAPrintf(&psz, "%s%u", rawdisk.raw(), + vrc = RTStrAPrintf(&psz, +#if defined(RT_OS_LINUX) + "%s%u", +#elif defined(RT_OS_FREEBSD) + "%ss%u", +#endif + rawdisk.raw(), partitions.aPartitions[i].uIndex); if (RT_FAILURE(vrc)) { >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103031851.p23Ip0Yd059319>