[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-API] Problem with writing to a VHD disk directly using blktap/libvhd


  • To: xen-api@xxxxxxxxxxxxx
  • From: Zahra Tarkhani <zhtarkhani@xxxxxxxxx>
  • Date: Mon, 18 Jan 2016 18:44:48 -0500
  • Delivery-date: Mon, 18 Jan 2016 23:45:02 +0000
  • List-id: User and development list for XCP and XAPI <xen-api.lists.xen.org>

Hello all,

I don't know whether here is the right place for asking my question or not. Actually I want to write a program for encrypting vhd disk sector by sector. I couldn't find any library to do it so I started to do it my self.Â

Now I'm trying to write a char array to a vhd disk using libvhd. But it failes with 'error number -22' ( -EINVAL /* Invalid argument */). There is no problem in opening and reading vhd disks using libvhd, but I can't find the problem Âthat causes the error when writing. Here is part of my code for writing:

vhd_context_t *ctx = NULL;
int size,err;
int z;

char *buf =(char *)malloc(VHD_SECTOR_SIZE);
z=vhd_unix_open("/home/zahra/Desktop/zahra/macemu/sys.vhd", &size, false, &ctx);
printf("z: %d \n",z);
/*reading a sector from a vhd disk*/
if ((err = vhd_io_read(ctx,  buf, (uint64_t)0 ,(uint32_t) 1))){
        printf("vhd read error %d \n", err);

}
BIO_dump_fp (stdout, (const char *)buf, size_t (VHD_SECTOR_SIZE));
/*reading is OK*/
/*writing check*/
  char * plaintext= (char *)"This is a writing test";  
if ((err = vhd_io_write(ctx,plaintext ,(uint64_t)0 ,(uint32_t)1))) {
            printf("vhd write error %d\n", err);
            printf("vhd footer current size %lld\n", ctx->footer.curr_size);}

Writing fails with 'vhd write error -22'.

Thank you,

Zahra

_______________________________________________
Xen-api mailing list
Xen-api@xxxxxxxxxxxxx
http://lists.xen.org/cgi-bin/mailman/listinfo/xen-api

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.