Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


added network harddisk support
[palacios.git] / palacios / src / devices / net_cd.c
index 0e2b49c..4446e12 100644 (file)
 #include <devices/ide.h>
 #include <palacios/vmm_socket.h>
 
-/* #ifndef DEBUG_IDE */
-/* #undef PrintDebug */
-/* #define PrintDebug(fmt, args...) */
-/* #endif */
-
+#ifndef DEBUG_IDE
+#undef PrintDebug
+#define PrintDebug(fmt, args...)
+#endif 
 
 
 #define NBD_READ_CMD 0x1
 #define NBD_WRITE_CMD 0x2
 #define NBD_CAPACITY_CMD 0x3
 
-
-
 #define NBD_STATUS_OK 0x00
 #define NBD_STATUS_ERR 0xff
 
@@ -58,12 +55,13 @@ struct cd_state {
 static int send_all(int socket, char * buf, int length) {
     int bytes_sent = 0;
     
+    PrintDebug("Sending %d bytes\n", length - bytes_sent);
     while (bytes_sent < length) {
-       PrintDebug("Sending %d bytes\n", length - bytes_sent);
        int tmp_bytes = V3_Send(socket, buf + bytes_sent, length - bytes_sent);
        PrintDebug("Sent %d bytes\n", tmp_bytes);
        
        if (tmp_bytes == 0) {
+           PrintError("Connection Closed unexpectedly\n");
            return -1;
        }
        
@@ -77,12 +75,13 @@ static int send_all(int socket, char * buf, int length) {
 static int recv_all(int socket, char * buf, int length) {
     int bytes_read = 0;
     
+    PrintDebug("Reading %d bytes\n", length - bytes_read);
     while (bytes_read < length) {
-       PrintDebug("Reading %d bytes\n", length - bytes_read);
        int tmp_bytes = V3_Recv(socket, buf + bytes_read, length - bytes_read);
        PrintDebug("Received %d bytes\n", tmp_bytes);
        
        if (tmp_bytes == 0) {
+           PrintError("Connection Closed unexpectedly\n");
            return -1;
        }
        
@@ -141,7 +140,7 @@ static int cd_read(uint8_t * buf, int block_count, uint64_t lba,  void * private
        return -1;
     }
 
-    PrintDebug("Reading Data\n");
+    PrintDebug("Reading Data (%d bytes)\n", ret_len);
 
     if (recv_all(cd->socket, (char *)buf, ret_len) == -1) {
        PrintError("Read Data Error\n");