Revision 8754dc49 src/host/HostShare.cc

View differences:

src/host/HostShare.cc
267 267
    return 1;
268 268
}
269 269

  
270

  
271
/* ------------------------------------------------------------------------*/
272
/* ------------------------------------------------------------------------*/
273

  
274
int HostSharePCI::set_pci_address(VectorAttribute * pci_device,
275
        const string& dbus)
276
{
277
    string        bus;
278
    ostringstream oss;
279

  
280
    unsigned int ibus, slot;
281

  
282
    // ------------------- DOMAIN & FUNCTION -------------------------
283
	pci_device->replace("VM_DOMAIN", "0x0000");
284
	pci_device->replace("VM_FUNCTION", "0");
285

  
286
    // --------------------------- BUS -------------------------------
287
    bus = pci_device->vector_value("VM_BUS");
288

  
289
    if ( bus.empty() )
290
    {
291
        bus = dbus;
292
    }
293

  
294
    istringstream iss(bus);
295

  
296
    iss >> hex >> ibus;
297

  
298
    if (iss.fail() || !iss.eof())
299
    {
300
        return -1;
301
    }
302

  
303
    oss << showbase << internal << setfill('0') << hex << setw(4) << ibus;
304

  
305
    pci_device->replace("VM_BUS", oss.str());
306

  
307
    // --------------------- SLOT (PCI_ID +1) -----------------------
308
    oss.str("");
309

  
310
    pci_device->vector_value("PCI_ID", slot);
311

  
312
    slot = slot + 1;
313

  
314
    oss << showbase << internal << setfill('0') << hex << setw(4) << slot;
315

  
316
    pci_device->replace("VM_SLOT", oss.str());
317

  
318
    // ------------------- ADDRESS (BUS:SLOT.0) ---------------------
319
    oss.str("");
320

  
321
    oss << noshowbase<<internal<<hex<<setfill('0')<<setw(2) << ibus << ":"
322
        << noshowbase<<internal<<hex<<setfill('0')<<setw(2) << slot << ".0";
323

  
324
    pci_device->replace("VM_ADDRESS", oss.str());
325

  
326
    return 0;
327
}
328

  
270 329
/* ------------------------------------------------------------------------*/
271 330
/* ------------------------------------------------------------------------*/
272 331

  

Also available in: Unified diff