명령 줄 전용 Debian guest와 함께 Virtualbox의 공유 클립 보드 7 호스트에 데비안 게스트가

Virtualbox를 사용하여 Windows 7 호스트에 데비안 게스트가 설치되어 있습니다. 설치에는 기본적으로 virtualbox-ose-guest-utils가 포함되어 있으므로 필요한 모든 것을 갖추어야합니다. 공유 클립 보드를 켜려면 어떻게해야합니까?



답변

명령 줄 전용 게스트에는 공유 클립 보드를 사용할 수 없습니다.

이는 TTY가 게스트 추가에 사용할 수있는 적절한 클립 보드를 실제로 생성하지 않기 때문에 전체 GUI가 필요하기 때문입니다.

SSH를 사용하여 호스트에서 게스트에 로그인하는 것이 좋습니다. 그렇게하면 Putty와 같은 SSH 클라이언트의 기능을 사용하여 클립 보드를 공유 할 수 있습니다.


답변

할 수 있습니다. 다음을 사용하여 양방향 작업을 수행 할 수 없었지만 Host to Guest (예 : 텍스트 콘솔에 내용 붙여 넣기)가 작동합니다. 다음 지침은 CentOS 5/6/7에 대한 것이지만 다른 맛에도 비슷한 메커니즘이 적용됩니다.

그러면 X11 클립 보드가 gpm 클립 보드와 동기화됩니다. 공유 클립 보드 설정이 “Host to Guest”로 구성된 경우 HostBox는 호스트 클립 보드가 변경 될 때 X11 클립 보드를 업데이트합니다. 패치 된 gpm은 xclip을 사용하여 X11 클립 보드 데이터를 gpm 클립 보드로 가져옵니다. 마우스 가운데 버튼.

공유 클립 보드

“Host to Guest”클립 보드 공유를 서버 / 콘솔 모드에서 작동시킬 수 있습니다. VBoxClient와 Xvfb 간의 문제로 인해 “Guest to Host”공유가 현재 작동하지 않습니다.

Xvfb 설치

    m 설치 Xvfb

VBoxClient 설치

    마운트 / dev / cdrom / mnt
    /mnt/VBoxLinuxAdditions.run

xclip 설치

xclip ( http://sourceforge.net/projects/xclip/ )을 / usr / local / bin / xclip으로 다운로드, 컴파일 및 설치 하십시오 .

패치 된 gpm 설치 (xclip 통합)

최신 gpm 소스를 다운로드하여 다음 변경 사항으로 패치하십시오.

바이너리를 / usr / local / bin / xclip-gpm으로 설치하십시오.

Alex Efros ( http://powerman.name/patch/gpm.html ) 가 업데이트 한 패치 버전입니다 .

gpm-1.20.7-xclip-support.patch

diff -rupN gpm-1.20.7-orig/src/daemon/do_selection.c gpm-1.20.7-xclip/src/daemon/do_selection.c
--- gpm-1.20.7-orig/src/daemon/do_selection.c   2012-10-27 10:21:38.000000000 +1300
+++ gpm-1.20.7-xclip/src/daemon/do_selection.c  2014-07-29 13:40:19.546689653 +1200
@@ -19,18 +19,49 @@
  *
  ********/

+#include <sys/stat.h>
+#include <sys/wait.h>
 #include "headers/message.h"        /* messaging in gpm */
 #include "headers/daemon.h"         /* daemon internals */
 #include "headers/gpmInt.h"         /* daemon internals */
+#include "headers/xcap.h"         /* daemon internals */

 /*-------------------------------------------------------------------*/
 int do_selection(Gpm_Event *event)  /* returns 0, always */
 {
    static int x1=1, y1=1, x2, y2;
+
+   /* XCaP start */
+   struct stat X0;
+   FILE *xclip;
+   /* XCaP end */
+
 #define UNPOINTER() 0

    x2=event->x; y2=event->y;
    switch(GPM_BARE_EVENTS(event->type)) {
+
+      /* XCaP start */
+      case GPM_UP:
+         if(event->buttons==GPM_B_LEFT) {
+             /* check Xwindow: if Xwindow not active - xclip freeze for 6 sec :( */
+             if (stat("/tmp/.X11-unix/X0", &X0) != -1) {
+                 if (!(xclip=popen("/usr/local/bin/xclip -d :0 -i", "w")))
+                     gpm_report(GPM_PR_OOPS,"open pipe");
+                 /* send currect selection to Xwindow clipboard */
+                 fwrite(sel_buffer, sizeof(char), sel_buffer_lth, xclip);
+                 if (!WIFEXITED(pclose(xclip)))
+                     gpm_report(GPM_PR_OOPS,"close pipe");
+             }
+             /*resize sel_buffer back to "normal" size*/
+             if(sel_buffer_lth>SCR_SIZE) {
+                 free(sel_buffer);
+                 sel_buffer=malloc(SCR_SIZE);
+                 sel_buffer_lth=SCR_SIZE;
+             }
+         }
+      /* XCaP end */
+
       case GPM_MOVE:
          if (x2<1) x2++; else if (x2>maxx) x2--;
          if (y2<1) y2++; else if (y2>maxy) y2--;
diff -rupN gpm-1.20.7-orig/src/daemon/loadlut.c gpm-1.20.7-xclip/src/daemon/loadlut.c
--- gpm-1.20.7-orig/src/daemon/loadlut.c    2012-10-27 10:21:38.000000000 +1300
+++ gpm-1.20.7-xclip/src/daemon/loadlut.c   2014-07-29 13:40:29.895722875 +1200
@@ -30,6 +30,8 @@
 #include "headers/daemon.h"         /* daemon internals */
 #include "headers/gpmInt.h"         /* GPM_SYS_CONSOLE  */

+#include "headers/xcap.h"
+
 int loadlut(char *charset)
 {
    int i, c, fd;
@@ -47,7 +49,9 @@ int loadlut(char *charset)
    };


+/*
 #define inwordLut (long_array+1)
+*/

    for (i=0; charset[i]; ) {
       i += getsym(charset+i, &this);
@@ -56,9 +60,15 @@ int loadlut(char *charset)
       else
          next = this;
       for (c = this; c <= next; c++)
-         inwordLut[c>>5] |= 1 << (c&0x1F);
+         (long_array+1)[c>>5] |= 1 << (c&0x1F);
    }

+   /* XCaP */
+   /* used in mode=1 (word-by-word selection) */
+   for (i=0; i<8; i++)
+      inwordLut[i] = long_array[i+1];
+   /* XCaP */
+
    if ((fd=open(option.consolename, O_WRONLY)) < 0) {
       /* try /dev/console, if /dev/tty0 failed -- is that really senseful ??? */
       free(option.consolename); /* allocated by main */
diff -rupN gpm-1.20.7-orig/src/daemon/old_main.c gpm-1.20.7-xclip/src/daemon/old_main.c
--- gpm-1.20.7-orig/src/daemon/old_main.c   2012-10-27 10:21:38.000000000 +1300
+++ gpm-1.20.7-xclip/src/daemon/old_main.c  2014-07-29 13:40:36.184743068 +1200
@@ -33,6 +33,8 @@
 #include "headers/daemon.h"         /* daemon internals */
 #include "headers/gpmInt.h"         /* daemon internals */

+#include "headers/xcap.h"         /* daemon internals */
+
 #ifndef max
 #define max(a,b) ((a)>(b) ? (a) : (b))
 #endif
@@ -73,6 +75,11 @@ int old_main()
       maxfd=max(fd, maxfd);
    }

+   /* XCaP start */
+   sel_buffer=malloc(SCR_SIZE);
+   sel_buffer_lth=SCR_SIZE;
+   /* XCaP end */
+
 /*....................................... catch interesting signals */

    signal(SIGTERM, gpm_killed);
diff -rupN gpm-1.20.7-orig/src/daemon/selection_copy.c gpm-1.20.7-xclip/src/daemon/selection_copy.c
--- gpm-1.20.7-orig/src/daemon/selection_copy.c 2012-10-27 10:21:38.000000000 +1300
+++ gpm-1.20.7-xclip/src/daemon/selection_copy.c    2014-07-29 13:40:42.677763908 +1200
@@ -22,11 +22,28 @@
 #include <fcntl.h>                  /* open              */
 #include <unistd.h>                 /* close             */
 #include <time.h>                   /* time              */
+#include <sys/kd.h>


 #include "headers/message.h"        /* messaging in gpm */
 #include "headers/daemon.h"         /* daemon internals */

+#include "headers/xcap.h"
+
+/* XCaP start */
+/* inword() from /usr/src/linux-2.4.19/drivers/char/selection.c */
+static inline int inword(const unsigned char c) {
+    return ( inwordLut[c>>5] >> (c & 0x1F) ) & 1;
+}
+/* atedge() from /usr/src/linux-2.4.19/drivers/char/selection.c */
+static inline int atedge(const int p, int size_row)
+{
+    /* p+2 changed to p+1 because kernel operate with screen address */
+    return (!(p % size_row) || !((p + 1) % size_row));
+}
+/* XCaP end */
+
+
 void selection_copy(int x1, int y1, int x2, int y2, int mode)
 {
 /*
@@ -37,6 +54,106 @@ void selection_copy(int x1, int y1, int
    unsigned short *arg = (unsigned short *)buf + 1;
    int fd;

+   /* XCaP start */
+   int i, j;              /* loop variables */
+   FILE *co_fptr;         /* file with current console image */
+   char scr[SCR_SIZE];            /* current console image */
+   int scr_lth;           /* current console image size */
+   char scrmap[E_TABSZ];   /* current screen map for inverse translation */
+   int p1, p2;                    /* cursor top/left and bottom/right position */
+   int n1, n2;                    /* selection top/left and bottom/right position */
+   int tmp;               /* temp integer */
+   char *bp, *obp;        /* temp pointers to fill sel_buffer */
+
+   /* read data from the console */
+   if( ((co_fptr=fopen("/dev/vcs","r"))==NULL) && /* usual /dev/ */
+      ((co_fptr=fopen("/dev/tty0","r"))==NULL) ) /*  */
+          gpm_report(GPM_PR_OOPS, "open /dev/vcs or /dev/tty0");
+   scr_lth = fread(&scr, sizeof(char), SCR_SIZE-1, co_fptr);
+   fclose(co_fptr);
+   scr[scr_lth] = 0;
+   /* unmap font translation */
+   /* ... is it possible to use kernel's inverse_translate() here? */
+   if ((fd=open_console(O_RDONLY))<0)
+      gpm_report(GPM_PR_OOPS,GPM_MESS_OPEN_CON);
+   if (ioctl(fd,GIO_SCRNMAP,&scrmap))
+      gpm_report(GPM_PR_OOPS,"GIO_SCRNMAP");
+   close(fd);
+   for (j=0; j<scr_lth; j++) {
+      for (i=0; i<E_TABSZ; i++)
+          if ((unsigned char) scrmap[i] == (unsigned char) scr[j])
+              break;
+      scr[j] = (char) i;
+   }
+   /* calc start-position and how many bytes to copy */
+   if (y1>y2) { tmp=y1; y1=y2; y2=tmp; tmp=x1; x1=x2; x2=tmp; }
+   if (y1==y2 && x1>x2) { tmp=x1; x1=x2; x2=tmp; }
+   p1 = (y1-1)*win.ws_col+x1-1;
+   p2 = (y2-1)*win.ws_col+x2-1;
+   n1 = 0;
+   n2 = 0;
+   /* selection logic from /usr/src/linux-2.4.19/drivers/char/selection.c */
+   if (mode==0) { /* character-by-character selection */
+      n1=p1;
+      n2=p2;
+   }
+   if (mode==1) { /* word-by-word selection */
+      tmp = isspace(scr[p1]);
+      for (n1 = p1; ; p1--) {
+          if ((tmp && !isspace(scr[p1])) || (!tmp && !inword(scr[p1])))
+              break;
+          n1 = p1;
+          if (!(p1 % win.ws_col))
+              break;
+      }
+      tmp = isspace(scr[p2]);
+      for (n2 = p2; ; p2++) {
+          if ((tmp && !isspace(scr[p2])) || (!tmp && !inword(scr[p2])))
+              break;
+          n2 = p2;
+          if (!((p2+1) % win.ws_col))
+              break;
+      }
+   }
+   if (mode==2) { /* line-by-line selection */
+      n1 = p1 - p1 % win.ws_col;
+      n2 = p2 + win.ws_col - p2 % win.ws_col - 1;
+   }
+   /* select to end of line if on trailing space */
+   if (n2 > n1 && !atedge(n2, win.ws_col) && isspace(scr[n2])) {
+      for (p2 = n2+1; ; p2++)
+          if (!isspace(scr[p2]) || atedge(p2, win.ws_col))
+              break;
+      if (isspace(scr[p2]))
+          n2 = p2;
+   }
+   /* save selection to sel_buffer */
+   if (mode<3) {
+      /* is the buffer big enough? */
+      if(((n2-n1+1)>=sel_buffer_lth) && ((n2-n1+1)>=SCR_SIZE)) {
+          free(sel_buffer);
+          sel_buffer=malloc((n2-n1+1)+1);
+      }
+      /* save selection, replac<C5> trailing spaces to \n in each line */
+      bp = sel_buffer;
+      obp= sel_buffer;
+      for (i = n1; i <= n2; i++ ) {
+          *bp = scr[i];
+          if (!isspace(*bp++))
+              obp = bp;
+          if (! ((i+1) % win.ws_col)) {
+              if (obp != bp) {
+                  bp = obp;
+                  *bp++ = '\n';
+              }
+              obp = bp;
+          }
+      }
+      sel_buffer_lth = bp - sel_buffer;
+      *(sel_buffer+sel_buffer_lth) = 0;
+   }
+   /* XCaP end */
+
    buf[sizeof(short)-1] = 2;  /* set selection */

    arg[0]=(unsigned short)x1;
diff -rupN gpm-1.20.7-orig/src/daemon/selection_paste.c gpm-1.20.7-xclip/src/daemon/selection_paste.c
--- gpm-1.20.7-orig/src/daemon/selection_paste.c    2012-10-27 10:21:38.000000000 +1300
+++ gpm-1.20.7-xclip/src/daemon/selection_paste.c   2014-07-29 13:40:48.754783436 +1200
@@ -22,15 +22,23 @@
 #include <time.h>                   /* time              */
 #include <fcntl.h>                  /* open              */
 #include <unistd.h>                 /* close             */
+#include <sys/wait.h>

 #include "headers/message.h"        /* messaging in gpm */
 #include "headers/daemon.h"         /* daemon internals */
+#include "headers/xcap.h"

 void selection_paste(void)
 {
    char c=3;
    int fd;

+   /* XCaP start */
+   int i;
+   struct stat X0;
+   FILE *xclip;
+   /* XCaP start */
+
    if (!opt_aged && (0 != opt_age_limit) &&
       (last_selection_time + opt_age_limit < time(0))) {
       opt_aged = 1;
@@ -41,9 +49,30 @@ void selection_paste(void)
       return;
    }

+   /* XCaP start */
+   /* check Xwindow: if Xwindow not active - xclip freeze for 6 sec :( */
+   if (stat("/tmp/.X11-unix/X0", &X0) != -1) {
+      if (!(xclip=popen("/usr/local/bin/xclip -d :0 -o", "r")))
+          gpm_report(GPM_PR_OOPS,"open pipe");
+      /* read Xwindow clipboard into current selection */
+      if ((i = fread(sel_buffer, sizeof(char), SCR_SIZE-1, xclip)) > 0)
+          *(sel_buffer+(sel_buffer_lth=i)) = 0;
+      if (!WIFEXITED(pclose(xclip)))
+          gpm_report(GPM_PR_OOPS,"close pipe");
+   }
+   fd=open_console(O_WRONLY);
+   for(i=0; i<sel_buffer_lth; i++)
+      if (ioctl(fd,TIOCSTI,&sel_buffer[i]) < 0)
+          gpm_report(GPM_PR_OOPS,"TIOCSTI");
+   close(fd);
+   return;            /* never paste from kernel buffer */
+   /* XCaP end */
+
+/*
    fd=open_console(O_WRONLY);
    if(ioctl(fd, TIOCLINUX, &c) < 0)
       gpm_report(GPM_PR_OOPS,GPM_MESS_IOCTL_TIOCLINUX);
    close(fd);
+*/
 }

diff -rupN gpm-1.20.7-orig/src/headers/xcap.h gpm-1.20.7-xclip/src/headers/xcap.h
--- gpm-1.20.7-orig/src/headers/xcap.h  1970-01-01 12:00:00.000000000 +1200
+++ gpm-1.20.7-xclip/src/headers/xcap.h 2014-07-29 13:40:53.619799026 +1200
@@ -0,0 +1,14 @@
+/*
+ * Xwindow Copy&Paste patch
+ * (c) 2002 Alex Efros <powerman@asdfGroup.com>
+ */
+
+#define SCR_SIZE 10240 /* current console image, for 80x25 needed only 2000 */
+
+#include <asm/types.h> /* __u32 */
+__u32 inwordLut[8];    /* used in gpn.c and gpm.c */
+
+char *sel_buffer;      /* buffer with current selection */
+int sel_buffer_lth;    /* size of buffer with current selection */
+
+
diff -rupN gpm-1.20.7-orig/src/prog/display-buttons.c gpm-1.20.7-xclip/src/prog/display-buttons.c
--- gpm-1.20.7-orig/src/prog/display-buttons.c  2012-10-27 10:21:38.000000000 +1300
+++ gpm-1.20.7-xclip/src/prog/display-buttons.c 2014-07-29 13:41:00.881822332 +1200
@@ -36,7 +36,7 @@
 #include <stdio.h>            /* printf()             */
 #include <time.h>             /* time()               */
 #include <errno.h>            /* errno                */
-#include <gpm.h>              /* gpm information      */
+#include <headers/gpm.h>              /* gpm information      */

 /* display resulting data */
 int display_data(Gpm_Event *event, void *data)

재부팅 후 시작하도록 구성

/etc/rc.local

# Support for a shared clipboard
(/usr/bin/Xvfb :0 >/dev/null 2>&1) &
sleep 1
DISPLAY=:0 /bin/VBoxClient --clipboard
/usr/local/bin/xclip-gpm -m /dev/input/mice -t exps2


답변

아직 구현되지 않았습니다. 6 년이 지난이 뛰어난 기능 요청을 참조하십시오.

https://www.virtualbox.org/ticket/1139


답변

Windows 클립 보드 내용을 게스트 Linux로 가져 오는 다른 방법으로 다른 사람이 유용하다고 생각하는 경우 여기에서 공유했습니다.

  • 첫째, 매우 유용한 설치 ClipX을 (나는 운이 좋았다에서 내가 이미 설치했고했다고 단지 내가이 복사 – 붙여 넣기 문제를 가로 질러 왔을 때 다른 이유로는 플러그인 목록을 검색되었다.)

  • ClipX DiskLog Plugin 1.2같은 페이지에서 설치

  • 시스템 트레이에서 ClipX 아이콘을 마우스 오른쪽 버튼으로 클릭하고 Configure파일 위치를 선택하십시오 (참고 :이 파일은 모든 클립 보드 내용을 저장하거나 개인 위치를 선택하거나 정기적으로 정리합니다).D:\Personal\clipboard\clip.txt

  • Linux 게스트에서 Virtualbox Guest 추가를 설치하십시오 (다른 곳에서 사용 가능한 지시 사항 및 X설치 중 관련 오류를 무시해도 필요한 “공유 폴더”기능이 계속 작동 함)

  • Virtualbox에서로 이동 Devices->Shared Folders하여 위의 폴더를 추가하고 D:\Personal\clipboard\이름을 지정하십시오 clipboard(이 시점에서 수동으로 드라이브를 마운트하지 않는 한 계속하기 전에 게스트를 다시 시작할 수 있음).

  • 이제 .bashrc(또는 .bash_aliases원하는 경우)에 별칭을 만드십시오.

    alias winclip='tail -n 1 /media/sf_clipboard/clip.txt'
    
  • 명령 줄에서 현재 Windows 클립 보드 내용을 사용하려면 $(winclip)해당 시점에서 사용하십시오 .

많은 단계처럼 보이지만 모두 몇 분 밖에 걸리지 않으며 VM 서버와 Putty 클라이언트를 실행 ssh하고이 간단한 기능을 수행 해야하는 번거 로움을 피할 수 있습니다. 그래도 양방향으로 만들 수있는 방법을 찾지 못했습니다. 제안은 환영합니다!


답변

이것이 Gnome 데스크탑 환경없이 설치 한 Debian 7.4.0 서버에서 양방향 클립 보드 지원을 활성화 한 방법입니다. VirtualBox 4.3.6을 사용하고 있습니다.

X 서버를 설치하고 시작하십시오.

apt-get install x-window-system-core && startx

클립 보드 지원을위한 xclip 설치

apt-get install xclip

Virtualbox가 게스트 추가를 구축 할 수 있도록 도구 설치

apt-get install bzip2 build-essential linux-headers-`uname -r`

게스트 추가 이미지를 마운트하고 추가를 설치하십시오.

mount /dev/cdrom /mnt && bash /mnt/VBoxLinuxAdditions.run

마지막으로으로 데비안을 다시 시작하십시오 shutdown -r now.

여기에 게스트 추가 설치 지침이 있습니다 . 이 블로그 항목 은 xclip을 사용자 정의하는 데 유용합니다.


답변